Ios5轻扫手势
我目前正在写一个ios5应用程序,并用button调用两个函数(后退)和(下一个)。 我想用滑动手势来打电话给他们。
这是可能的,怎么样?
谢谢
向右方向(下一个button)和向左方向(后退button)使用滑动手势对于左方向:
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) }