Detail View won't show up when clicking from TableView Row
I've got an XCode iPHone project setup with the following:
My App Delegate creates a dynamic tabBarController and adds two view controllers to it. One of them contains a TableView.
From that TableView, I want the user to be able to click the Blue arrow button on each item and get more details about it. It's a pretty standard thing... here's the code I have to do that:
-(void)tableView: (UITableView *)tableView accessoryButtonTappedForRowWithIndexPath:(NSIndexPath *) indexPath {
[self tableView:tableView didSelectRowAtIndexPath:indexPath];
}
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
// Navigation logic may go here. Create and push another view controller.
[tableView deselectRowAtIndexPath:indexPath animated:NO];
if (self.switchView == nil) {
SwitchViewController *viewController = [[SwitchViewController alloc] initWithNibName:@"SwitchViewController" bundle:[NSBundle mainBundle]];
self.switchView = viewController;
[viewController release];
}
[self.navigationController pushViewController:self.switchView animated:YES];
self.switchView.title = @"Test Title";
}
开发者_开发技巧
Right now, my SwitchViewController is nothing but a blank view with a button on it. When the user clicks the blue button, nothing happens. I can put a breakpoint in and see all the code being executed, but the iPhone screen simply doesn't change.
Any tips? I'm sure this is something basic, as I'm pretty new to iOS development.
Thanks in advance!
R
From your answer to Vladmir's question in the comments it's clear you don't have a UINavigationController initialized. So try something like this:
UINavigationController *navController = [[UINavigationController alloc] initWithRootViewController:tableViewController];
Then add navController to your tabBarController instead of the tableViewController.
精彩评论