I have a NavigationController in which there is a TableView. A TV cell has a โmodalโ segment that points to a TableViewController (class: Details.h / .m). When I select a cell, I take it in the TableViewController, as expected.
However, I need to add the following functions:
1) click on the destination so that I get a good return button.
2) transmit various information about the object in the selected cell in the target TCEs.
To do this, I perform the following tasks:
1) Change segue to "push" and give it the identifier "segueToDetails"
2.1) add code to didSelectRowAtIndexPath method (below)
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath { [self performSegueWithIdentifier:@"segueToDetails" sender:self]; }
2.2) add code to prepareForSegue method (below)
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender { NSIndexPath *selectedIndexPath = [self.tableView indexPathForSelectedRow]; NSInteger rowNumber = selectedIndexPath.row; myObject = (MyObject *) [myArray objectAtIndex:rowNumber]; Details *details = [segue destinationViewController]; details.detailsObject = myObject; }
2.3) to confirm that information about the object is transmitted to the recipient, I output some data using NSLog (below)
- (void)viewDidLoad { [super viewDidLoad]; NSLog(@"name: %@", detailsObject.name); }
Now, when I start the project and select the cell in the table that I get in the target TCE, I see the result from NSLog, which is good. I also have a nice back button. But wait, when I press back, I have another back button! By pressing this button back, I will return to where I came from. The debugger window displays this message every time I go to the target TCE.
2012-01-24 13:55:58.240 MyApp[26875:11603] nested push animation can result in corrupted navigation bar 012-01-24 13:55:58.593 MyApp[26875:11603] Finishing up a navigation transition in an unexpected state. Navigation Bar subview tree might get corrupted. 2012-01-24 13:55:58.593 MyApp[26875:11603] Unbalanced calls to begin/end appearance transitions for <SpotDetails: 0x7a7a370>.
Any suggestions to fix this?
PS - I am using Xcode 4.2 w / ARC, iOS 5