开发者

MGSplitViewController Not As Root

开发者 https://www.devze.com 2023-03-25 04:54 出处:网络
I need to use an MGSplitViewController because of it\'s ability to show the master view controller in the portrait mode. However, before displaying my split view, I need to display a login screen. Unf

I need to use an MGSplitViewController because of it's ability to show the master view controller in the portrait mode. However, before displaying my split view, I need to display a login screen. Unfortunately I am unable to pop the view controller in fullscreen at startup because of some other methods that I have called! Below, is my app delegate and detail view controller codes. Please note, that the selector methods prevent me from opening a modal!

AppDelegate.h was constructed using MGSplitViewControllerAppDelegate.h

// RandomStringAppDelegate.m
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {    

    // Override point for customization after app launch.
    // Set the split view controller as the window's root view controller and display.
    //self.window.rootViewController = self.splitViewController;
    // Add the split view controller's view to the window and display.

    NSUserDefaults *prefs = [NSUserDefaults standardUserDefaults];
    [prefs setObject:@"YES" f开发者_如何学CorKey:@"FirstRun"];


    [window addSubview:splitViewController.view];

    [window makeKeyAndVisible];


    [rootViewController performSelector:@selector(selectFirstRow) withObject:nil afterDelay:0];
    [splitViewController performSelector:@selector(toggleMasterView:) withObject:nil afterDelay:0];
    [detailViewController performSelector:@selector(configureView) withObject:nil afterDelay:0];

    //[self.window makeKeyAndVisible];

    return YES;
}

Everything Else is Standard! Unfortunately, I cannot pop the modal here because it crashes on me!


You could derive a class from MGSplitViewController and handle your things in viewDidLoad or viewWillAppear: in that class. So you could track your prefs key "FirstRun" and if it's set to "YES" you hide your splitview while you start your modal in viewDidLoad. I think this could do the job. btw you're missing a [prefs synchronize] in your code above, so you won't have the key written back.

0

精彩评论

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