我目前正在编写一个 ios5 应用程序并使用按钮调用两个函数(返回)和(下一步)。我想用滑动手势给他们打电话。
那可能吗?怎么做?
谢谢
对右方向(下一个按钮)和左方向(后退按钮)使用滑动手势对于左方向:
UISwipeGestureRecognizer *swipeLeft =[[UISwipeGestureRecognizer alloc]
initWithTarget:self action:@selector(didSwipeLeft:)];
swipeLeft.direction=UISwipeGestureRecognizerDirectionLeft;
swipeLeft.numberOfTouchesRequired = 1;
[self.view addGestureRecognizer:swipeLeft];
[swipeLeft release];
对于正确的方向:
UISwipeGestureRecognizer *swipeRight =[[UISwipeGestureRecognizer alloc]
initWithTarget:self action:@selector(didSwipeRight:)];
swipeRight .direction=UISwipeGestureRecognizerDirectionRight;
swipeRight .numberOfTouchesRequired = 1;
[self.view addGestureRecognizer:swipeRight ];
[swipeRight release];
你用事件处理它们:
-(void)didSwipeRight
{
//For right direction (next button)
}
-(void)didSwipeLeft
{
//For left direction (back button)
}