私はビューベースのアプリを使用し、プログラムでTabBarを生成しました。問題は次のとおりです。
タブバーコントローラーを備えた2つのタブ項目があるIphoneアプリケーションがあります。タブバーコントローラー内では、各ビューコントローラーはナビゲーションコントローラーです。2番目のタブを選択すると、ビューコントローラーがあります。 self.navigation controller.and そのviewcontrollerで私はプッシュして、そのように行きます.しかし、問題は、私がtabitemを再度選択しているときに、pushviewcotrollerがそこに表示されることです.しかし、タブを選択しているときに、そこにrootviewが再度必要です
AppDelegate.m の私のコードは次のとおりです。
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
self.window = [[[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]] autorelease];
UINavigationController *nc1;
nc1 = [[UINavigationController alloc] init];
UIViewController *viewController1 = [[[ViewController alloc] initWithNibName:@"ViewController" bundle:nil] autorelease];
nc1.viewControllers = [NSArray arrayWithObjects:viewController1, nil];
UINavigationController *nc2;
nc2 = [[UINavigationController alloc] init];
UIViewController *viewController2 = [[[secondview alloc] initWithNibName:@"secondview" bundle:nil] autorelease];
nc2.viewControllers = [NSArray arrayWithObjects:viewController2, nil];
self.tabBarController = [[[UITabBarController alloc] init] autorelease];
self.tabBarController.viewControllers = [NSArray arrayWithObjects:nc1,nc2,nil];
self.window.rootViewController=self.tabBarController;
[self.window makeKeyAndVisible];
return YES;
}