I am creating a very simple sample application to show how the settings will work with the new application I'm working on. The process is very simple: create a UINavigationController in IB, assign it a view controller, which will be the root view controller, and push the new view controller onto the stack of the navigator controller when callSelectRowAtIndexPath is called.
I read so many related topics that I could find and did not find a satisfactory answer.
The problem is that when you press the back button, the navigation controller animates back, but the view itself does not change back, which means that it does not appear.
This is the code that I use to push a new view controller onto the stack. This is pretty standard. I added NSLog to make sure it gets only once.
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
if(indexPath.section != 0)
return;
NSLog(@"didSelectRowAtIndexPath\n");
PrefsListTableViewController *prefsListTableViewController = [[PrefsListTableViewController alloc] initWithNibName:@"PrefsListTableViewController" bundle:nil];
[self.navigationController pushViewController:prefsListTableViewController animated:YES];
[prefsListTableViewController release];
}
To check if the call to viewWillDisappear falls into the second view, I added it to my PrefsListTableViewController:
- (void)viewWillDisappear:(BOOL)animated
{
[super viewWillDisappear:animated];
NSLog(@"ptvc viewWillDisappear");
}
It never hits.
Firstly, I got the impression that you donβt need to encode anything to handle the back button, since the UINavigationController should automatically pop up the stack when you press the back button. I can show that with the sample application that I have that does what I do, but the sample is just code. Code from Erica Sadun iPhone Cookbook code, recipe 11-11. Her code is here:
https://github.com/erica/iphone-3.0-cookbook-/tree/master/C11-Tables/11-Disclosure%20Chevrons
, .xib , . , -, , . .xib, , .
-, NSLog, , .
2011-11-18 11:14:36.355 TableViewTest[58011:207] didSelectRowAtIndexPath
2011-11-18 11:14:36.358 TableViewTest[58011:207] ptvc viewWillAppear (
"<TableViewController: 0x8923d40>",
"<PrefsListTableViewController: 0x8927a20>"
)
2011-11-18 11:14:36.717 TableViewTest[58011:207] ptvc viewDidAppear (
"<TableViewController: 0x8923d40>",
"<PrefsListTableViewController: 0x8927a20>"
)
, , .
: PrefsListTableViewController ""? - , , .