在我的應用程序中,我有4個選項卡,在第一個選項卡上:我有4個視圖。在第二個視圖中,有一個按鈕將打開第三個標籤視圖。但我選擇的標籤索引是一個。我怎樣才能把它變成第三。更改所選的TabBar索引按鈕單擊
我對標籤的條形碼是的appdelegate如下:
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
UINavigationController *nav1 = [[UINavigationController alloc] init];
UIViewController *viewController1 = [[[CarAccidentAppViewController alloc]
initWithNibName:@"CarAccidentAppViewController_iPhone" bundle:nil]
autorelease];
nav1.viewControllers = [NSArray arrayWithObjects:viewController1, nil];
//for steps tab...
UINavigationController *nav2 = [[UINavigationController alloc] init];
UIViewController *viewController2 = [[[FirstSteps alloc] initWithNibName:@"FirstSteps" bundle:nil] autorelease];
nav2.viewControllers = [NSArray arrayWithObjects:viewController2, nil];
//for profiles tab...
UINavigationController *nav3 = [[UINavigationController alloc] init];
UIViewController *viewController3 = [[[Profiles alloc] initWithNibName:@"Profiles" bundle:nil] autorelease];
nav3.viewControllers = [NSArray arrayWithObjects:viewController3, nil];
//for contact us tab...
UINavigationController *nav4 = [[UINavigationController alloc] init];
UIViewController *viewController4 = [[[ContactUs alloc] initWithNibName:@"ContactUs" bundle:nil] autorelease];
nav4.viewControllers = [NSArray arrayWithObjects:viewController4, nil]; self.tabBarController = [[[UITabBarController alloc] init]
autorelease];
self.tabBarController.viewControllers = [NSArray arrayWithObjects:nav1,nav2,nav3,nav4 ,nil];
self.window.rootViewController=self.tabBarController;
[self.window makeKeyAndVisible];
return YES;
}
在我的應用程序 – piyush
沒有工作你在你的代碼放置.. – Rajneesh071
此作品在我的應用程序很好,我回答說:到我意識到Rajneesh071發佈相同的代碼片段之前的問題。 – Plasma