0

可以禁用/启用 popviewcontroller 的默认向左滑动事件。例如,当我在主视图中触摸 DetailViewController 向左滑动时,我正在使用默认的“主细节应用程序”模板。这是如何实现的?

4

1 回答 1

0

您可以实现 UISwipeGestureRecognizer,如下所示:

UISwipeGestureRecognizer *swipeBack = [[UISwipeGestureRecognizer alloc] initWithTarget:self action:@selector(popView)];
swipeBack.numberOfTouchesRequired = 1;
swipeBack.direction = UISwipeGestureRecognizerDirectionRight;
[self.view addGestureRecognizer:swipeBack];

只需将其放在您要执行手势的位置即可。一个安全的地方是viewDidLoad你想要从 VC 中刷回来的地方。

确保包含定义选择器的方法popView。它会是这样的:

- (void)popView
{
    [self.navigationController popViewControllerAnimated:YES];
}
于 2013-09-02T15:54:33.987 回答