MGSplitViewController不是根 [英] MGSplitViewController Not As Root
问题描述
我需要使用MGSplitViewController,因为它能够以纵向模式显示主视图控制器。但是,在显示我的拆分视图之前,我需要显示一个登录屏幕。不幸的是,我无法在启动时以全屏方式弹出视图控制器,因为我调用了一些其他方法!下面是我的应用程序委托和详细视图控制器代码。请注意,选择器方法阻止我打开一个模态!
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" forKey:@"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!
急需帮助!
推荐答案
你可以从MGSplitViewController派生一个类,并在该类中处理你的东西在viewDidLoad或viewWillAppear:。所以你可以跟踪你的prefs键FirstRun,如果它设置为YES,你隐藏你的splitview,而你在viewDidLoad启动模态。我认为这可以做到这一点。 btw你在上面的代码中缺少一个[prefs synchronize],所以你不会把密钥写回来。
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.
这篇关于MGSplitViewController不是根的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!