I am working on an app that displays a list of places. There is a NavigationController, and in the navigation bar I have some UIBarButtonItem (left and right), and the center section is a custom view with a label and two UIButton's.
The map button performs a segue to a MapViewController that displays the points on a map. What I want to achieve is that the navigation bar of the map ViewController also displays the same custom UIView (showing the arrow buttons and the Day Label), but I don't know how to achieve this. I've tried to copy the view on prepareForSegue:
-(void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender{
if ([segue.identifier isEqualToString:@"FlipFromListToMap"]) {
if ([segue.destinationViewController isKindOfClass:[DisplayTourMapViewController class]]){
DisplayTourMapViewController *cityListController = segue.destinationViewController;
cityListController.navigationItem.titleView = self.navigationItem.titleView;
}
}
}
But this is not working. Furthermore, when a go back the navigation view from the original table view is gone:
I'd like to know whether my approach is wrong or not. Can I keep the navigationcontroller views between segues? Is it ok that I am using navigationcontroller and segue's? Or should I just have two views inside the controller and swap them programatically? The model for the two views is the same, it only changes the way I present the information (map or list).
Thanks in advance.