2

我似乎无法让 PresentWithGesture 工作。我需要能够根据显示的详细视图控制器打开和关闭它。

- (IBAction)disableGestures:(id)sender
{
    AppDelegate *appDelegate = [UIApplication sharedApplication].delegate;
    appDelegate.splitViewController.presentsWithGesture = NO;

    NSLog(@"Disable Gestures!");
}

我整理了一个简单的项目(使用默认的 UISplitViewController 模板): http ://www.filedropper.com/splitviewtest

这不是 PresentWithGesture 的预期用途吗?

4

4 回答 4

1

设置presentsWithGesture为 NO(或 false)后,您还应该在主视图控制器和详细视图控制器中禁用interactivePopGestureRecognizerfromUINavigationController实例:

override func viewWillAppear() {
    super.viewWillAppear()

    self.navigationController?.interactivePopGestureRecognizer?.enabled = false
}

这对我有用。

于 2015-11-10T19:20:41.520 回答
0

看起来您只能presentsWithGesture在 AppDelegate 中进行更改。

我的解决方案是禁用它并添加一个我可以控制的 UISWipeGestureRecognizer。

于 2012-12-05T18:19:47.907 回答
0

SplitView 类型应用程序的代码

如果你想在横向模式下禁用手势,那么下面的代码对你来说是完整的

步骤 1 在 detailView.h 中导入 #AppDelegate.h

step-2 在 detailView.h 中实现这个方法

- (BOOL)splitViewController:(UISplitViewController *)svc
   shouldHideViewController:(UIViewController *)vc
          inOrientation:(UIInterfaceOrientation)orientation
{
    AppDelegate *appDelegate = [UIApplication sharedApplication].delegate;
    appDelegate.splitViewController.presentsWithGesture = NO;

    return YES;
}
于 2012-12-05T09:24:59.480 回答
0

通过将此代码添加到您的详细视图控制器(应该是 UISplitViewControllerDelegate),将拆分视图控制器属性 PresentWithGesture 设置为 No

- (BOOL)splitViewController: (UISplitViewController *) svc
   shouldHideViewController: (UIViewController *) vc
              inOrientation: (UIInterfaceOrientation) orientation
{
   svc.presentsWithGesture = NO;

   return YES;
}
于 2014-02-28T18:35:55.673 回答