0

我有两个视图,我想使用向右平移手势(如 Facebook ios 应用程序中使用的手势)切换到第二个视图。一旦我们开始使用平移手势,视图应该开始改变。我该如何执行这个?有没有人有执行此操作的示例代码?

4

1 回答 1

0

有一个带有示例项目的 git,您可以通过该项目参考 Facebook iOS 应用程序中的侧面菜单效果。

https://github.com/BenHall/ios_facebook_style_navigation

编辑:

好的,然后尝试这样的事情:

   UISwipeGestureRecognizer *swipeLeft = [[UISwipeGestureRecognizer alloc] initWithTarget:self action:@selector(scrollViewSwipedLeft:)];
   [swipeLeft setDirection:UISwipeGestureRecognizerDirectionLeft];
   [self.navigationController.navigationBar addGestureRecognizer:swipeLeft];

然后用这样的方式处理滑动:

-(void) didSwipedLeft: (UISwipeGestureRecognizer *) gesture {

  if (gesture.state != UIGestureRecognizerStateEnded) {
      return;
  }

  //do something    
}
于 2013-01-10T06:43:15.847 回答