ich benutze einen tabBarController, um Fotos anzuzeigen, und jede Art von Fotos sind in jedem Register, , so dass ich eine ViewController.xib, und wie verschiedene Inhalte (Navigation Item und ImageView) in jedem Tab?wie man zwei gleiche ViewController.xib in tabBarController verwendet
und meine Frage ist: wo und wie Codes nächsten Schritt schreiben, tut die Codes in - (void) tabBarController oder in 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;
}
}
was genau ist das problem? funktioniert Ihre Lösung für zwei Controller oder nicht? Die Idee, mehrere Instanzen desselben Controllers zu erstellen, ist in Ordnung. – kuba
bittank Sie, John Smith, die beiden Controller funktioniert, aber –
(pls ingore den obigen Kommentar, ha) danke, John Smith, die beiden Controller funktioniert, aber ich weiß nicht, wo und wie Codes nächsten Schritt zu schreiben, tut die Codes in - (void) tabBarController oder in PhotoController.m? –