开发者

UISplitViewController with UINavigationController

开发者 https://www.devze.com 2023-04-05 00:31 出处:网络
I\'m a beginner in the iOS world. I would like to have an app that is based on UISplitViewController, however on some cases a button on the detail view (which is UINavigationController) will open a UI

I'm a beginner in the iOS world. I would like to have an app that is based on UISplitViewController, however on some cases a button on the detail view (which is UINavigationController) will open a UI on the entire screen (with back button which will take back to splitViewContr开发者_C百科oller). Does the only option (legitimate from apple), is modeling it with ModalView?


I'm not sure off the top of my head whether it's 'HIG-friendly', but you could implement something whereby when the user clicks the button, you send a message back to your AppDelegate and tell it to swap your splitViewController with your fullScreenViewController at the window level.

For example, in your AppDelegate.m:

- (void)showFullScreenController
{
    if (self.splitViewController.superview != nil) {    // Just check that the split view controller is currently showing
        FullScreenViewController *newFullScreenController = [[FullScreenViewController alloc] initWithNibName:@"FullScreenViewController" bundle:nil];
        self.fullScreenController = newFullScreenController;
        [newFullScreenController release];

        [self.splitViewController viewWillDisappear:YES];    // "YES" assumes you are animating the transition
        [self.fullScreenController viewWillAppear:YES];

        // Remove old view and add new one.
        [self.splitViewController.view removeFromSuperview];
        [window addSubview:self.fullScreenController.view];

        [self.splitViewController viewDidDisappear:YES];
        [self.fullScreenController viewDidAppear:YES];

        self.splitViewController = nil;
    }
}

This method can easily be turned into a 'view switching' method by utilising the corresponding else statement and loading the splitViewController instead.

Hope this helps.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号