2013-08-01 2 views
1

일주일 내 탭 제스처 인식기를 추가했지만 다른 모든 작업을 수행 한 것처럼이 작업을 수행하고 응용 프로그램이 다운됩니다. 나는 뭔가를 놓쳐 버렸을 것이다. 그러나 나에게있어서 나는 그것이 무엇인지를 알 수 없다. 필자는이 버그에 관한 12 가지 이상의 기사를 읽었지만 아무런 도움이되지 못했습니다.또 다른 "NSInvalidArgumentException : 인스턴스로 보낸 인식 할 수없는 선택자"게시

이 코드 :

2013-08-01 12:50:11.027 tyrionSwipe[27336:11303] -[UIView onTap:]: unrecognized selector sent to instance 0xe52c4a0 
2013-08-01 12:50:11.029 tyrionSwipe[27336:11303] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[UIView onTap:]: unrecognized selector sent to instance 0xe52c4a0' 
*** First throw call stack: 
(0x1c91012 0x10cee7e 0x1d1c4bd 0x1c80bbc 0x1c8094e 0x2dd85a 0x2dc99b 0x2de0df 0x2e0d2d 0x2e0cac 0x2d8a28 0x45972 0x45e53 0x23d4a 0x15698 0x1becdf9 0x1becad0 0x1c06bf5 0x1c06962 0x1c37bb6 0x1c36f44 0x1c36e1b 0x1beb7e3 0x1beb668 0x12ffc 0x295d 0x2885 0x1) 
libc++abi.dylib: terminate called throwing an exception 

사람이 도와 드릴까요 :

@interface wwfpViewController() 
@property (nonatomic, strong) UIView * firstScreen; 
@end 

@implementation wwfpViewController 

@synthesize firstScreen; 

- (void)viewDidLoad { 
    [super viewDidLoad]; 
    firstScreen=[[UIView alloc] initWithFrame:self.view.frame]; 
    [firstScreen setBackgroundColor:[UIColor redColor]]; 
    [self.view addSubview:firstScreen]; 

    UITapGestureRecognizer * tap=[[UITapGestureRecognizer alloc] initWithTarget:firstScreen action:@selector(onTap:)]; 
    [tap setNumberOfTapsRequired:1]; 
    [firstScreen addGestureRecognizer:tap]; 
} 

- (void) onTap:(UIGestureRecognizer*) recogniser { 
    NSLog(@"tap: %@",recogniser); 
} 

@end 

이 오류를 생성?

편집 : 오타를 만들었습니다! 죄송합니다. 오타가 없어도이 오류가 계속 발생합니다.

답변

6

그것은 당신의 방법 ONTAP또는 탭에서 선택 이름을 그냥 오타 입니다 :ONTAP에 :

대상 살펴보고, 나는 확신 당신 firstScreen이 UIView 일 뿐이므로 자아를 의미합니다.

+0

잘못된 것이 었습니다! 많은 도움을 주셔서 감사합니다 :) – Jimmery

0

잘못된 셀렉터를 호출하고 있습니다. 귀하의 이름 onTap으로 선택을 작성 tap

UITapGestureRecognizer * tap=[[UITapGestureRecognizer alloc] initWithTarget:firstScreen action:@selector(tap:)]; 

사용을 호출이

UITapGestureRecognizer * tap=[[UITapGestureRecognizer alloc] initWithTarget:firstScreen action:@selector(onTap:)]; 
- (void) onTap:(UIGestureRecognizer*) recogniser { 
    NSLog(@"tap: %@",recogniser); 
} 
0

대상은 firstScreen이며, 당신의 선택은 wwfpViewController 내부에 정의된다. 목표를 스스로 변경해야합니다. firstScreen은 UIView입니다.

- [UIView onTap :]은 정의되지 않은 것에 대해 불평하는 것입니다.

+0

죄송합니다. 이미 읽었습니다 :-) – ahwulf

관련 문제