0
我使用tabBarController來顯示照片,並且每種照片都顯示在每個標籤中,因此我使用一個ViewController.xib,以及如何顯示不同的內容(導航項目和ImageView)在每個選項卡中?如何在tabBarController中使用兩個相同的ViewController.xib
我的問題是: 哪裏和如何編寫下一步代碼,在 - (void)tabBarController或PhotoController.m中的代碼? -
- (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;
}
}
究竟是什麼問題?你的兩個控制器的解決方案是否工作?創建同一控制器的多個實例的想法是可以的。 – kuba 2012-04-10 18:23:51
butthank you,John Smith。兩個控制器工作,但是 – 2012-04-11 01:26:07
(請參閱上面的評論,哈哈)謝謝你,約翰史密斯。兩個控制器的工作,但我不知道下一步在哪裏和如何編寫代碼,是嗎?在 - (void)tabBarController或PhotoController.m中的代碼? – 2012-04-11 01:46:21