How to acces the right navigation controller inside storyboard

≡放荡痞女 提交于 2019-12-12 00:45:05

问题


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.

For example what is the difference between accessing NAV 1 and accessing NAV 2 or NAV 3 ... .

Any help? Thank you

Code for setting title

- (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];




}

回答1:


The answer is there in your storyboard itself.

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

EDIT : Setting the title in a VC

[self.navigationItem setTitle:@"Title"];

ReEdit:

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];


来源:https://stackoverflow.com/questions/14768859/how-to-acces-the-right-navigation-controller-inside-storyboard

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!