如果您想使用导航控制器,请这样做:
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
//for home tab.. u want to add navigation controller
YourTableViewController *objviewController = [[[YourTableViewController alloc] initWithNibName:@"YourTableViewController_iPhone" bundle:nil] autorelease];
UINavigationController *navCtrl = [[UINavigationController alloc] initRootViewController:objviewController];
//for tab2...
YourSecondViewController *objYourSecondViewController = [[[YourTableViewController alloc] initWithNibName:@"YourSecondViewController_iPhone" bundle:nil] autorelease];
//for tab3...
YourThirdViewController *objYourThirdViewController = [[[YourThirdViewController alloc] initWithNibName:@"YourThirdViewController_iPhone" bundle:nil] autorelease];
self.tabBarController = [[[UITabBarController alloc] init] autorelease];
self.tabBarController.viewControllers = [NSArray arrayWithObjects:navCtrl,objYourSecondViewController,objYourThirdViewController,nil];
self.window.rootViewController=self.tabBarController;
[self.window makeKeyAndVisible];
return YES;
}
但是如果不需要导航控制器,你也可以添加:
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
DetailViewController *nextController = [self.storyboard instantiateViewControllerWithIdentifier:@"detailView"];
[self.view addSubView:nextController];
}