간단한 데모 응용 프로그램을 사용하여 UITextView를 UIView 바로 뒤에 (배경으로) 직접 추가하려고합니다.UIPanGestureRecognizer가 UIView 대상을 받아들이지 않습니다.
가 - [UIView의 detectPan이 :] :하지만 컴파일하고 팬 동작을 테스트 할 때마다, 나는이 오류 얻을 인식 할 수없는 선택기 인스턴스에 전송을 여기
0x17e7fc30 내가 만들 어디에 내 샘플 코드되고있는 UIView의과 일부 인트가 있습니까
-(void)detectPan:(UIPanGestureRecognizer *)gr {
NSLog(@"inside detectPan");
}
:
CGRect textFieldFrame = CGRectMake(0, 44, 320, 44);
// Create a TextField
UITextField *textField = [[UITextField alloc] initWithFrame:textFieldFrame];
textField.userInteractionEnabled = NO;
textField.layer.zPosition = 100001;
[self.view addSubview:textField];
// Create the Text Background View
UIView *textBG = [[UIView alloc] initWithFrame:textFieldFrame];
textBG.layer.zPosition = 100000;
[self.view addSubview:textBG];
self.panRecognizer = [[UIPanGestureRecognizer alloc] initWithTarget:textBG action:@selector(detectPan:)];
그리고 내 detectPan 방법 다음 UIPanGesture를 할당 p 구현에 누락 되었습니까? 나는이 똑같은 접근 방식이 과거에는 나를 위해 일했다고 맹세하지만 지금은 전혀 작동하지 않는다. 매우 혼란스러워! 이 initWithTarget:self
에 initWithTarget:textBG
를 변경 시도하고 사물이 작동해야 -initWithTarget:action:
에서 단어 "대상"으로 오해하기 쉬운 때문에
컨트롤에 제스처를 추가 했습니까? – channi
[self.view addGestureRecognizer : self.panRecognizer]; –