是否有标准的方法来注册页面的左或右滑动并做出相应的响应?
答案 0 :(得分: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];
并在- (void)swipeLeftGesture:(UISwipeGestureRecognizer *)sender
和- (void)swipeRightGesture:(UISwipeGestureRecognizer *)sender
中,您可以随心所欲。
答案 1 :(得分:1)