LoginSignup
2
0

More than 5 years have passed since last update.

TabBarControllerのMoreを編集不可にする

Last updated at Posted at 2015-10-27

ちょっと引っ掛かったのでメモ。

標準

標準
右上のEditで編集できる。

編集不可にする

TabBarController.m
self.customizableViewControllers = nil;

こうすればEditが消えて編集不可になる。
編集不可

ただし!(ここで引っ掛かった)

customizableViewControllers = nilの後でviewControllersを変更するとcustomizableViewControllersが初期化されてしまう。
例えば、こんなことをすると、

TabBarController.m
//編集不可にする
self.customizableViewControllers = nil;
//ViewControllerを追加する
NSMutableArray *array = self.viewControllers.mutableCopy;
UIViewController *vc = UIViewController.new;
vc.tabBarItem = [[UITabBarItem alloc] initWithTabBarSystemItem:UITabBarSystemItemMostViewed tag:0];
[array addObject:vc];
self.viewControllers = array;

このありさま。
このありさま

なので、順番を逆にする。

TabBarController.m
//ViewControllerを追加する
NSMutableArray *array = self.viewControllers.mutableCopy;
UIViewController *vc = UIViewController.new;
vc.tabBarItem = [[UITabBarItem alloc] initWithTabBarSystemItem:UITabBarSystemItemMostViewed tag:0];
[array addObject:vc];
self.viewControllers = array;
//編集不可にする
self.customizableViewControllers = nil;

完璧。
完璧

2
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
2
0