MGSplitViewController 不是根
我需要使用 MGSplitViewController 因为它能够以纵向模式显示主视图控制器。但是,在显示分割视图之前,我需要显示登录屏幕。不幸的是,由于我调用了一些其他方法,我无法在启动时以全屏方式弹出视图控制器!下面是我的应用程序委托和详细视图控制器代码。请注意,选择器方法阻止我打开模式!
AppDelegate.h 是使用 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;
}
其他都是标准的! 不幸的是,我无法在这里弹出模式,因为它崩溃了!
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!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您可以从 MGSplitViewController 派生一个类,并在该类中的 viewDidLoad 或 viewWillAppear: 中处理您的内容。因此,您可以跟踪您的首选项键“FirstRun”,如果它设置为“YES”,您将在 viewDidLoad 中启动模式时隐藏 splitview。我认为这可以完成这项工作。顺便说一句,您在上面的代码中缺少 [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.