2010-02-22 46 views
1

我是iphone開發新手。我創建了一個基於視圖的應用程序。現在我想在該視圖中的標籤欄。標籤欄的第一個視圖是一個表視圖,第二個視圖是Web視圖。所有教程只解釋基於標籤欄的應用程序。因爲我使用基於視圖的應用程序,我發現它真的很難。如何使用接口構建器來實現它。請指導我。任何示例教程將更加有用。請幫助我。謝謝。基於視圖的應用程序中的選項卡欄?

+0

你可以重新啓動它作爲「標籤欄應用程序」嗎? – kennytm 2010-02-22 12:22:29

+0

這是一個重複的http://stackoverflow.com/questions/2326814/how-to-add-tabbarcontroller-in-viewcontroller-in-iphone/ – 2010-03-03 19:16:34

+0

@ Kristopher ..我問這個問題9天前,和pugal問他的問題7天后,我可以如何複製它? – Warrior 2010-03-03 19:23:43

回答

4

試試這個。此代碼以編程方式創建標籤欄應用程序。所以點擊按鈕就會打開視圖中的標籤欄。

-(IBAction) clkBtn:(id) sender 
    { 

    UITabBarController *tabbar1 = [[UITabBarController alloc] init]; 

    firstViewController *first = [[firstViewController alloc] initWithNibName:@"firstViewController" bundle:nil]; 

    UINavigationController *tabItem1 = [[[UINavigationController alloc] initWithRootViewController: first] autorelease]; 

    secondViewController *second = [[secondViewController alloc] initWithNibName:@"secondViewController" bundle:nil]; 

    UINavigationController *tabItem2 = [[[UINavigationController alloc] initWithRootViewController: second] autorelease]; 

    tabbar1.viewControllers = [NSArray arrayWithObjects:tabItem1, tabItem2,nil]; 

    [self.view insertSubview:tabbar1.view belowSubview: first.view]; 

    [self presentModalViewController:tabbar1 animated:YES]; 

    } 

感謝,

好運。

+0

這是否適用於推視圖控制器? – Warrior 2010-06-09 14:56:57

+0

@戰士。是的,因爲在視圖中添加了導航控制器。所以它推動了這個觀點。 – Pugal 2010-06-09 15:13:18

+0

Thanks.It是一個非常好的答案 – Warrior 2010-06-09 15:17:06

相關問題