2012-12-05 12 views
2

我似乎無法得到presentsWithGesture工作。我需要能夠基於顯示的詳細視圖控制器打開和關閉它。UISplitViewController presentsWithGesture不工作

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

    NSLog(@"Disable Gestures!"); 
} 

我已經把一個簡單的項目(使用默認UISplitViewController模板): http://www.filedropper.com/splitviewtest

這是不是有意使用presentsWithGesture的?

回答

0

看起來你只能在AppDelegate的改變presentsWithGesture

我的解決方案是禁用它並添加一個我可以控制的UISWipeGestureRecognizer。

+3

presentsGithGesture應設置之前設置代表。所以你不能在委託設置後禁用它。 – ZYiOS

0

代碼SPLITVIEW型應用

如果妳要禁用橫向模式,然後下面的代碼上的手勢是使用全爲ü

第1步進口#AppDelegate.h在detailView.h

步-2 detailView.h實現此方法

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

    return YES; 
} 
+0

感謝您的嘗試,但正如您在示例代碼中看到的,我已經這樣做了。 – christo16

0

集拆分視圖控制器屬性presentsWithGesture到沒有通過將此代碼添加到您的詳細視圖控制器(這應該是一個UISplitViewControllerDelegate)

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

    return YES; 
} 
1

設置presentsWithGesture爲NO(或錯誤)之後,還應該禁用在interactivePopGestureRecognizerUINavigationController情況下,在主機和細節viewcontrollers:

override func viewWillAppear() { 
    super.viewWillAppear() 

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

這奏效了我。

+0

謝謝! – JackyW

相關問題