iPhone NavigationController自动加载到三个级别

编程入门 行业动态 更新时间:2024-10-07 08:21:20
本文介绍了iPhone NavigationController自动加载到三个级别的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我创建了navigationController项目名称:autoload, 然后创建两个名为uiviewContorller的名称:second,three

i create i navigationController project name:autoload, then create two uiviewContorller named: second,three

我想让进程加载rootView方法中的第二个加载方法:"viewDidLoad",然后在方法"viewdidload"中自动加载三个方法, 这是代码:

i want the process is load rootView the load second in method:"viewDidLoad" then auto load three in method"viewdidload", here is the code:

rootView:

- (void)viewDidLoad { self.title = @"first"; Second *second = [[Second alloc] init]; AutoLoadAppDelegate *delegate = [[UIApplication sharedApplication] delegate]; [delegate.navigationController pushViewController:second animated:YES]; [super viewDidLoad]; }

秒:

- (void)viewDidLoad { self.title = @"second"; [super viewDidLoad]; }

现在构建一个程序,我可以自动加载到第二个非常正确的位置 包括标题内容和导航按钮

now build an go the program, i can auto load to second very correct includeing the title content and also the navgation button

然后我想在第二秒内加载aotoload,所以在第二种方法中添加代码:"viewdidload"

then i want aotoload three in second,so add the code in second method:"viewdidload"

秒:

- (void)viewDidLoad { self.title = @"second"; **Three *three = [[Three alloc] init]; AutoLoadAppDelegate *delegate = [[UIApplication sharedApplication] delegate]; [delegate.navigationController pushViewController:three animated:YES];** [super viewDidLoad]; }

最后将标题添加到三个:

finaly add the title to three:

三个:

- (void)viewDidLoad { self.title = @"three"; [super viewDidLoad]; }

然后构建并运行,您会发现内容正确的是三个" 但是标题错误的是第二",应该是三个" 而且您还会发现导航按钮是错误的

then build and go, you will find that the content is right "three" but the title is wrong "second", it should be "three" and you will also find the navgation button is wrong

我的那是什么错,我应该怎么做才能实现自动加载到三个的程序?

what's wrong with my that,what i should do to implement the program of autoload to three?

注意:

我尝试: 如果我第二秒钟添加一个按钮并移动代码

i try that : if i add a button in second and move the code

Three *three = [[Three alloc] init]; AutoLoadAppDelegate *delegate = [[UIApplication sharedApplication] delegate]; [delegate.navigationController pushViewController:three animated:YES];

对于ibaction,它将是正确的工作,但我希望它自动加载

to the ibaction ,it will be work correct, but i want it load automaticly

推荐答案

而不是在viewDidLoad方法中调用pushViewController,请尝试在applicationDidFinishLaunching方法中设置viewControllers数组:

Instead of calling pushViewController in the viewDidLoad methods, try setting the viewControllers array in the applicationDidFinishLaunching method:

- (void)applicationDidFinishLaunching:(UIApplication *)application { RootViewController *root = [[RootViewController alloc] init]; root.title = @"root"; Second *second = [[Second alloc] init]; second.title = @"second"; Three *three = [[Three alloc] init]; three.title = @"three"; [navigationController setViewControllers:[NSArray arrayWithObjects:root,second,three,nil] animated:YES]; [root release]; [second release]; [three release]; [window addSubview:[navigationController view]]; [window makeKeyAndVisible]; }

更多推荐

iPhone NavigationController自动加载到三个级别

本文发布于:2023-08-03 14:36:48,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1287714.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:级别   自动加载   iPhone   NavigationController

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!