在app启动时在splitviewcontroller上呈现模态viewcontroller

时间:2013-09-16 18:07:47

标签: ios ipad ios6 uisplitviewcontroller modalviewcontroller

由于需要将UISplitViewController作为rootviewcontroller,我试图在app启动时以模态方式呈现一个viewcontroller,作为用户的登录/欢迎屏幕。显然我的AppDelegate.m中的以下代码应该使用IOS 6:

#import "AppDelegate.h"
#import "WelcomeViewController.h"

@implementation AppDelegate

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
// Override point for customization after application launch.

WelcomeViewController *modalWelcomeView = [[WelcomeViewController alloc] initWithNibName:@"Welcome" bundle:nil];
[modalWelcomeView setModalPresentationStyle:UIModalPresentationFullScreen];
[self.splitViewController presentViewController:modalWelcomeView animated:NO Completion:nil];

return YES;
}

但是我在return YES;以上的行上找到了“AppDelegate'类型对象上找不到”属性'splitViewController'。我担心我做的事情很傻......

有什么建议吗?非常感谢。

1 个答案:

答案 0 :(得分:4)

唉我找到了解决方案,实际上需要在AppDelegate.m

中采用略有不同的方法
#import "AppDelegate.h"
#import "WelcomeViewController.h"

@implementation AppDelegate

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
// Override point for customization after application launch.
UIStoryboard *storyboard = [UIStoryboard storyboardWithName:@"MainStoryboard" bundle:nil];
WelcomeViewController *modalWelcomeView = [storyboard instantiateViewControllerWithIdentifier:@"Welcome"];
[self.window makeKeyAndVisible];
[self.window.rootViewController presentViewController:modalWelcomeView animated:NO completion:NULL];

return YES;