How to remove a navigationController (iPhone)
My app has couple of normal views (V1, V2), without a navigationController, but when and ADD button is pushed creates a view with a navigationController like this:
CreateNewEventViewController.m
- (void)viewDidLoad {
[super viewDidLoad];
tableViewController = [[NewEventTableViewController alloc] init];
navigationController = [[UINavigationController alloc] initWithRootViewController:tableViewController];
tableViewController.navigationController.title = @"Add";
[self.view addSubview:navigationController.view];
}
so the NewEventTableViewController is an UITableViewController. When done filling the data from the table, last cell is a button to save it and then go back to one of the main views (V1, V2).
NewEventTableViewController.m
V1 *myV1 = [[V1 alloc] init];
[self.view.superview addSubview:myV1.view];
but the navigationController I had stays. Any way of removing it?
update I've tried this, but all I get is a white screen. Also removing after adding the new view. (this code is placed in NewEventTableViewController)
[self.navigationController.view remove开发者_StackOverflow中文版FromSuperview];
V1 *myV1 = [[V1 alloc] init];
[self.view addSubview:myV1.view];
update 2 Is not what I really needed but anyway I can use this.
[self.navigationController.view.superview removeFromSuperview];
it removes the navigationController and it's table view and it displays the view I had before I call the CreateNewEventViewController.
Not much sure why you wanna do that, but there is a possibility to hide navigationController
self.navigationController.navigationBarHidden = YES;
精彩评论