Search code examples
iosipadmodal-dialoguisplitviewcontrolleruipopovercontroller

iOS - show modal popover view controller over splitviewcontroller at startup


I'm working on an iPad app which requires a login screen. I'd like the login screen to appear as a modal popover in the centre of the screen, over the top of the underlying screen which is controlled by a UISplitViewController. Ideally I'd like the 'master' view to be hidden and then appear after a successful login. I understand my UISplitViewController has to be the root controller, so I need to launch the popover from either the master or detail view at an appropriate event. I'm a bit stuck as to where this should happen, and whether the UIPopoverController should be a property of the master or detail views.

Any help greatly appreciated,

Jonathan


Solution

  • Here are some leads for what you are trying to achieve:

    Show / Hide master view: By default the master view is visible in portrait mode. As mentioned in the apple doc you can alter this behavior starting ios5. You can play with this method to achieve the display or not of the master view for any orientation.

     - (BOOL)splitViewController:(UISplitViewController *)svc shouldHideViewController:(UIViewController *)vc  inOrientation:(UIInterfaceOrientation)orientation
    

    Display a modal popover in the center of the screen Your modal popover view needs to be presented from the SplitViewController when the application is launched. I have seen in this post a possible way to do this in the didFinishLaunchingWithOptionsYou shouldn't launch the popover from either the master or the detail controller.