0
我必须在我的视图控制器中使用滑动功能。因此,无论何时Iam滑动,我的滑动方法都会被调用两次,而且我在(swipe :)方法中写入的NSlogs正在显示内容两次。滑动方法被调用两次
这是我使用的代码。
UIView *swipeView=[[UIView alloc]initWithFrame:CGRectMake(405, 420, 265, 35)];
swipeView.backgroundColor=[UIColor clearColor];
[self.view addSubview:swipeView];
UISwipeGestureRecognizer *gesture;
gesture=[[UISwipeGestureRecognizer alloc]initWithTarget:self action:@selector(swipe:)];
[gesture setDirection:(UISwipeGestureRecognizerDirectionRight)];
[swipeView addGestureRecognizer:gesture];
[gesture release];
[swipeView release];
-(void)swipe:(UISwipeGestureRecognizer *)recognizer {
NSLog(@"Swipe received.");
NSLog(@"HIJ");
}
请告诉我,我只需要调用一次就可以做什么。