私は tabBarController を使用して写真を表示し、各種類の写真が各タブに表示されるため、1 つの 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;
}
}