[英]How to use UINavigationController outside the AppDelegate?
in my current app i´m using a UINavigationController to display the contents of other viewControllers. 在我当前的应用程序中,我正在使用UINavigationController来显示其他viewController的内容。 Its installed within the appDelegate like this.
这样安装在appDelegate中。
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
self.viewController = [[ViewController alloc] init];
UINavigationController* navigationController = [[UINavigationController alloc] initWithRootViewController:self.viewController];
[navigationController.navigationBar setBarStyle:UIBarStyleBlackOpaque];
[self.window addSubview:navigationController.view];
[[self window] setRootViewController:navigationController];
[self.window makeKeyAndVisible];
return YES;
}
What i want now is creating a new view controller that displays an intro video right after the splash screen. 我现在想要的是创建一个新的视图控制器,在启动屏幕之后立即显示一个介绍性视频。 When the video playback has completed, i want to push my "StartViewController" and install the UINavigationController on it.
视频播放完成后,我要推送“ StartViewController”并在其上安装UINavigationController。 So that would mean i would setup within one of my others ViewControllers, right?
因此,这意味着我将在其他ViewController中设置一个,对吗?
Is that possible? 那可能吗? Any help on that?
有什么帮助吗? Thanks for your time.
谢谢你的时间。
you can do this like i do below 你可以像我下面那样做
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
capturedImg = [[UIImage alloc]init];
self.splash = [[UIImageView alloc] initWithFrame:self.window.frame];
splash.image = [UIImage imageNamed:@"default.png"];
[self.window addSubview:splash];
[self performSelector:@selector(Load_FirstView) withObject:nil afterDelay:2];
[self.window makeKeyAndVisible];
}
and the Load_FirstView method 和Load_FirstView方法
-(void)Load_FirstView
{
MasterViewController *masterViewController = [[MasterViewController alloc] initWithNibName:@"MasterViewController" bundle:nil];
self.navigationController = [[UINavigationController alloc] initWithRootViewController:masterViewController];
[self.window makeKeyAndVisible];
}
if you want to show video just put one other method and place it between this two methods ie call it first and then from it call Load_firstView method 如果要显示视频,只需放置另一个方法并将其放置在这两个方法之间,即先调用它,然后从中调用Load_firstView方法
thanks for your fast reply. 感谢您的快速回复。 I´ve also just found an interesting blogpost about splash screens:
我还刚刚发现了一个有关启动屏幕的有趣博客文章:
http://lucas.tiz.ma/blog/2011/09/26/ios-splash-screens-done-right/ http://lucas.tiz.ma/blog/2011/09/26/ios-splash-screens-done-right/
For me, that way works. 对我来说,这种方式有效。 And it seems, it a nice flexible way.
看起来,这是一种很好的灵活方式。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.