我只需要在特殊区域捕捉滑动操作。但调试器告诉unrecognized selector sent to instance
滑动时无法识别的选择器
- (void)viewDidLoad
{
UISwipeGestureRecognizer *swipeLeft = [[UISwipeGestureRecognizer alloc]
initWithTarget:self.viewName action:@selector(didSwipe:)];
swipeLeft.direction = UISwipeGestureRecognizerDirectionLeft;
[self.view addGestureRecognizer:swipeLeft];
}
-(void)didSwipe:(UISwipeGestureRecognizer*)swipe{
NSLog(@"swiped left");
}
怎么了?
好吧,它确实有效,但与所有屏幕。只有在特殊区域开始时,我如何才能使用此手势? – 2012-03-20 16:34:02
即使如此。我需要这个滑动功能不会在除了很小的区域以外的任何地方工作:) – 2012-03-20 16:37:31
如果它需要在某个区域,您不应该将手势识别器添加到整个'self.view'中。尝试将其添加到正确位置的子视图中,以便用户在其中滑动。 – MishieMoo 2012-03-20 16:40:56