1
我有一個情景板場景是UITabBarController
場景,它有大約5個標籤欄項目。我想要做的是根據用戶的捆綁設置刪除一兩個項目。所以,我創建了一個UITabBarController
.h
和.m
文件像這樣:從UITabBarController場景中刪除標籤欄項目
.H:
#import <UIKit/UIKit.h>
@interface LHTabBarController : UITabBarController
@end
.H:
#import <Foundation/Foundation.h>
#import "LHTabBarController.h"
@implementation LHTabBarController
-(void)viewDidLoad
{
/*NSMutableArray *tabbarViewControllers = [NSMutableArray arrayWithArray: [self.tabBarController viewControllers]];
[tabbarViewControllers removeObjectAtIndex:1];
[self.tabBarController setViewControllers: tabbarViewControllers];*/
[super viewDidLoad];
}
-(void)viewWillAppear:(BOOL)animated
{
[super viewWillAppear:animated];
[super viewDidAppear:animated];
}
-(void)didReceiveMemoryWarning
{
[super didReceiveMemoryWarning];
}
@end
,我在此連接類的UITabBarController
我故事板。
我嘗試了註釋掉的代碼,但是這給了我一個數組,表示數組是空的。
如何從此類中刪除標籤欄項目?
錯誤'爲「NSArray的」不可見@interface聲明選擇「removeObjectAtIndex: ' – user979331
我的壞....你需要使它nsmutablearray ...我會更新我的答案 –
NSArray不是可編輯陣列。你必須使它可變,然後刪除你不需要的對象 –