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");
}
請告訴我,我只需要調用一次就可以做什麼。