Forcing an iPad app to show splitView even in Portrait orientation(Like the Settings iPad app)

前端 未结 9 1397
不知归路
不知归路 2020-12-16 08:25

I am trying to develop a splitView based iPad app, that displays the split interface in every orientation. I have tried subclassing the UISplitViewController class as given

9条回答
  •  生来不讨喜
    2020-12-16 08:32

    In the viewController class that implements the UISplitViewControllerDelegate Protocol (usually the DetailViewController), add the following code.

    - (BOOL) splitViewController:(UISplitViewController *)svc shouldHideViewController:(UIViewController *)vc inOrientation:(UIInterfaceOrientation)orientation {   
        return NO;
    }
    

    According to the Docs, this has been available since iOS 5.

    To see it in action:
    -open Xcode.
    -Create a new Master/Detail app.
    -Add the above code to the DetailViewController
    -Run in the iPad simulator.

    In your own project you'll want to add the following line to the viewDidLoad method of the detailViewController.

    self.splitViewController.delegate = self;
    

提交回复
热议问题