ipad页面滑动

ema*_*ine 1 iphone xcode objective-c ipad

是否有标准方法来注册页面的左或右滑动并做出相应的响应?

Mat*_*uch 5

如果你说的是页面,我不知道你的意思,但除此之外还有UIGestureRecognizers.还有一个UISwipeGestureRecognizer.一个不那么明显(至少对我而言)的事情是你必须创建其中两个,一个用于左边,一个用于右边滑动.只需将它们添加到UIView即可.

UISwipeGestureRecognizer *swipeLeftGestureRecognizer = [[UISwipeGestureRecognizer alloc] initWithTarget:self action:@selector(swipeLeftGesture:)];
swipeLeftGestureRecognizer.direction = UISwipeGestureRecognizerDirectionLeft;
[aView addGestureRecognizer:swipeLeftGestureRecognizer];
[swipeLeftGestureRecognizer release];

UISwipeGestureRecognizer *swipeRightGestureRecognizer = [[UISwipeGestureRecognizer alloc] initWithTarget:self action:@selector(swipeRightGesture:)];
[aView addGestureRecognizer:swipeRightGestureRecognizer];
[swipeRightGestureRecognizer release];
Run Code Online (Sandbox Code Playgroud)

- (void)swipeLeftGesture:(UISwipeGestureRecognizer *)sender- (void)swipeRightGesture:(UISwipeGestureRecognizer *)sender你可以做任何你想要的.

您应该查看UIGestureRecognizer类参考