Modal segue, navigation bar disappears

前端 未结 11 1204
既然无缘
既然无缘 2020-12-01 04:30

I\'m using Xcode 4.6.1 to code on Objective-C. I want to know how can I keep the navigation bar shown when I create a modal segue between 2 View controllers, because I\'m do

11条回答
  •  [愿得一人]
    2020-12-01 04:38

    There is an easier way to do this. Like previous comments said (but didn't explain all the steps) you need to embed your desired destination view controller in a navigation controller, then set your destination view controller to be the Navigation Controller, then the Navigation controller calls the destination view controller.

    First, embed the VC in a NavVC. Then you must write the code to set the segue destination to be the Nav VC.

    The code looks like this:

    - (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender
    {
        UINavigationController *nav = segue.destinationViewController;
        AddTriviaVC *triv = [[AddTriviaVC alloc]init];
        triv = nav.viewControllers[0]; 
        triv.location = self.location; 
    } 
    

    I hope this makes sense.

提交回复
热议问题