ビューコントローラーでスワイプ機能を使用する必要があります。そのため、スワイプするたびに、スワイプ メソッドが 2 回呼び出され、(swipe:) メソッド内で記述した NSlogs にコンテンツが 2 回表示されます。
これが私が使用したコードです。
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");
}
一度だけ呼び出すにはどうすればよいか教えてください。