0
我有一個UITabBarController,並希望只在其中一個選項卡上看到按鈕,而不是其他選項。所以在我的方法,當按下標籤欄來處理,我將按鈕添加這樣的:在使用UITabBarController的特定視圖上的UIBarButtonItem
#pragma mark - UITabBarController delegate
- (void) tabBarController:(UITabBarController *)tabBarController didSelectViewController:(UIViewController *)viewController
{
// check for what type of class you are based on the tab pressed
...
NSMutableArray *barItems = [[self.MainToolbar items] mutableCopy];
UIBarButtonItem *sortBarButtonItem = [[UIBarButtonItem alloc] initWithTitle:@"Sort" style:UIBarButtonItemStyleBordered target:self action:@selector(SortButtonPressed:)];
[barItems insertObject:sortBarButtonItem atIndex:0];
[self.MainToolbar setItems:barItems];
現在我該怎樣在其他視圖時,刪除它時不打擾他們的按鈕在UIToolBar按下tabBarController他們IB中已經添加了這些內容。
只要檢查視圖控制器是否是特定的視圖控制器。 – Legolas