我使用 tabBarController 来显示照片,每种照片都显示在每个选项卡中,所以我使用一个 ViewController.xib ,以及如何在每个选项卡中显示不同的内容(导航项和 ImageView)?
我的问题是:下一步在哪里以及如何编写代码,是 -(void)tabBarController 还是 PhotoController.m 中的代码?——</p>
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
self.window = [[[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]] autorelease];
UIViewController *photoController1 = [[[PhotoController alloc] initWithNibName:@"PhotoController" bundle:nil] autorelease];
UIViewController *photoController2 = [[[PhotoController alloc] initWithNibName:@"PhotoController" bundle:nil] autorelease];
self.tabBarController = [[[UITabBarController alloc] init] autorelease];
self.tabBarController.viewControllers = [NSArray arrayWithObjects:
,photoController1
,photoController2
,nil];
self.tabBarController.delegate=self;
self.window.rootViewController = self.tabBarController;
[self.window makeKeyAndVisible];
return YES;
}
- (void)tabBarController:(UITabBarController *)tabBarController didSelectViewController:(UIViewController *)viewController
{
switch (tabBarController.selectedIndex)
{
case 4:
//how to write code;
break;
case 5:
//how to write code;
default:
break;
}
}