如何在故事板中访问正确的导航控制器 [英] How to acces the right navigation controller inside storyboard
问题描述
你可以在这里看到我的故事板.
You can see my storyboard over here.
我现在的问题是我应该如何以正确的方式在代码中访问不同的导航控制器.因为有时我会遇到一些麻烦.
My question is now how should I access in code the different navigation controllers in a correct way. Because sometimes I get some troubles with it.
例如,访问 NAV 1 和访问 NAV 2 或 NAV 3 之间有什么区别.......
For example what is the difference between accessing NAV 1 and accessing NAV 2 or NAV 3 ... .
有什么帮助吗?谢谢
设置标题的代码
- (void)addEvent:(id)sender {
NSLog(@"pressed event");
EKEventEditViewController *addController = [[EKEventEditViewController alloc] initWithNibName:nil bundle:nil];
// set the addController's event store to the current event store.
addController.eventStore = self.eventStore;
addController.editViewDelegate = dataSource;
// present EventsAddViewController as a modal view controller
addController.title = @"";
self.title = @"";
self.parentViewController.title = @"";
self.navigationController.parentViewController.title = @"";
self.navigationController.visibleViewController.title = @"";
self.navigationController.title = @"";
self.navigationItem.title = @"";
addController.navigationItem.title = @"";
addController.navigationController.title = @"";
self.tabBarController.navigationController.title = @"";
[self presentModalViewController:addController animated:YES];
}
推荐答案
答案就在你的故事板中.
The answer is there in your storyboard itself.
Nav1 是将屏幕推到选项卡 1 的根导航控制器.在那里您正在创建单独的导航控制器并启动另一个导航流程.因此要获得导航 2,剩下的您必须依赖于 tabcontroller 选项卡1
Nav1 is the root navigation controller that pushes the screens upto the tab 1 .There you are creating separate Navigation controllers and the flow of another navigation is started.so to get the Nav 2 and remaining you have to depend on the tabcontroller tab 1
在 VC 中设置标题
[self.navigationItem setTitle:@"Title"];
重新
插入导航控制器并模态呈现导航控制器
Insert a navigation controller and modally present the navigation controller
EKEventEditViewController* myController = [[EKEventEditViewController alloc] init];
myController.title = @"My Title";
UINavigationController* modalController = [[UINavigationController alloc] initWithRootViewController:myController];
[self presentViewController:modalController animated:YES completion:nil];
[modalController release];
[myController release];
这篇关于如何在故事板中访问正确的导航控制器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!