2009-11-04 27 views
0

我在我的應用程序中有三個標籤欄項目的UITabBar。iPhone + UITabBar

在某些情況下,我想顯示所有三個標籤欄項目和一些情況下,我想隱藏Tabbar中的第三個標籤欄項目。

請幫我

回答

3

發送setItems:animated:消息到UITabBar。例如:

// get array of current UITabBarItem objects 
NSMutableArray *tabBarItems = [tabBarViewController.items mutableCopy]; 

// modify the array (remove or add UITarBarItem objects as appropriate) here 

// animate the changes to the UITabBar 
[tabBarViewController.tabBar setItems:tabBarItems animiated:YES]; 
+0

如果創建一個NSArray,我該如何修改它(添加/刪除它的對象),因爲它不可變。 – pratik 2009-11-13 11:00:58

+0

我更新了代碼以使用NSMutableArray。 – gerry3 2009-11-13 16:34:55