我有一個簡單的演示應用程序,我試圖動態地添加一個UITeView和它後面的UIView(作爲背景)。但我每次編譯和測試移動手勢的時候,我得到這個錯誤:UIPanGestureRecognizer不接受UIView目標
- [UIView的detectPan:]:無法識別的選擇發送到實例0x17e7fc30
這裏是我的示例代碼中,我創建了UIView的和分配UIPanGesture:
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方法:
-(void)detectPan:(UIPanGestureRecognizer *)gr {
NSLog(@"inside detectPan");
}
有一些STE p我在執行中失蹤?我發誓,這種完全相同的方法在過去對我有效,但現在它根本不起作用。很混亂!
您是否向任何控件添加了手勢? – channi 2014-10-28 13:13:46
[self.view addGestureRecognizer:self.panRecognizer]; – 2014-10-28 13:22:46