I am surely losing my mind. I have coded what I assume to be a fairly standard usage of the
didSelectRowAtIndexPath: method here:
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
NSInteger row = [indexPath row];
if (row == 0){
BuildingDescriptionViewController *buildingDescriptionViewController = [[BuildingDescriptionViewController alloc] initWithNibName:@"BuildingDescriptionViewController" bundle:[NSBundle mainBundle]];
NSLog(@"self.navigationController0 is %@", self.navigationController ? @"not nil" : @"nil");
[self.navigationController pushViewController:buildingDescriptionViewController animated:YES];
[buildingDescriptionViewController release];
}
else if (row == 1){
PostCommentViewController *buildingCommentViewController = [[PostCommentViewController alloc] init];
NSLog(@"self.navigationController1 is %@", self.navigationController ? @"not nil" : @"nil");
[self.navigationController pushViewController:buildingCommentViewController animated:YES];
[buildingCommentViewController release];
}
}
The NSLog informs that the navigationController is NOT nil, but nothing else happens. Neither viewController appears. In fact, just the NSLog occurs. Is there some esoteric usage I am missing? I have also tried [self presentModalViewController:buildingDescriptionViewController animated:YES]; and nothing happened. I could really use some assistance.
Thanks.
UPDATE:
Output per Sailesh’s suggestion below
2011-06-27 18:02:56.370 something[16331:207] buildingdecriptionviewcontrollerinit
2011-06-27 18:02:56.370 something[16331:207] ViewControllers before pushing: (
“BuildingProfileViewController: 0x7e89680”
)2011-06-27 18:02:56.370 something[16331:207] ViewControllers after pushing: (
“BuildingProfileViewController: 0x7e89680>”,
“BuildingDescriptionViewController: 0x7e73d30”
)2011-06-27 18:03:15.843 something[16331:207] buildingdecriptionviewcontrollerinit
2011-06-27 18:03:15.844 something[16331:207] ViewControllers before pushing: (
“BuildingProfileViewController: 0x7e89680”,
“BuildingDescriptionViewController: 0x7e73d30”
)2011-06-27 18:03:15.844 something[16331:207] ViewControllers after pushing: (
“BuildingProfileViewController: 0x7e89680”
“BuildingDescriptionViewController: 0x7e73d30”
“BuildingDescriptionViewController: 0xcc2c8e0”
)
I finally found the problem. I was confused by the fact that the self.navigationController wasn’t NIL. The issue was that the tableView had been added as a subview. I fixed it by pushing its viewController onto the navigation stack. Thanks to everyone that replied.