在app启动时在splitviewcontroller上呈现模态viewcontroller [英] Presenting modal viewcontroller over splitviewcontroller at app startup

查看:182
本文介绍了在app启动时在splitviewcontroller上呈现模态viewcontroller的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

Due to the need for UISplitViewController to be rootviewcontroller, I am trying instead to present a viewcontroller modally at app startup to act as a login/welcome screen for the user. Apparently the following code in my AppDelegate.m should do the trick with 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;
}

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

yet I get a "Property 'splitViewController' not found on object of type 'AppDelegate'" for the line above return YES;. I fear I'm doing something silly...

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

Any suggestions? Many thanks.

推荐答案

唉我找到了解决方案,实际上在 AppDelegate.m中需要稍微不同的方法

Alas I found the solution, actually required a slightly different approach in 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;

这篇关于在app启动时在splitviewcontroller上呈现模态viewcontroller的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆