ios – 编辑按钮不显示在UITabBarController的MoreNavigationController中

一个UITabBarController被推到堆栈上:
let presenter = presentingViewController as! UINavigationController
let tabvc = UITabBarController()
tabvc.viewControllers = vcs
tabvc.customizableViewControllers = vcs
presenter.pushViewController(tabvc,animated: true)

一旦呈现,更多的标签按钮正确显示,但编辑按钮重新排列标签栏不会.根据docs on the MoreNavigationController

The interface for the standard More item includes an Edit button that
allows the user to reconfigure the tab bar. By default,the user is
allowed to rearrange all items on the tab bar. If you do not want the
user to modify some items,though,you can remove the appropriate view
controllers from the array in the customizableViewControllers
property.

我的猜测是,导航控制器中的标签栏不快乐.有关将编辑按钮重新启动的任何想法?

解决方法

你可以同时拥有一个UINavigationController和一个UITabBarController;使用Storyboard可以更好地了解问题,任何这些解决方案都可以正常工作:

>使用UITabBarController作为初始视图控制器
>使用presentViewController而不是pushViewController
>使用模态故事板segue执行模态演示
>动态地切换rootViewController

初始视图控制器设计

Tab Bar控制器为初始View Controller时,编辑按钮正常显示.

推送设计

一个导航控制器是初始视图控制器,使用5个自适应Action Segue之一:

>显示
>自定义

– >没有编辑按钮,因为它与父级UITableViewController直接冲突.

>显示详细信息
>现在模态
> Popover演示

– >编辑按钮按预期显示.

程序模态

使用问题中提供的确切代码,更改最后一行:

let presenter = presentingViewController as! UINavigationController
let tabvc = UITabBarController()
tabvc.viewControllers = vcs
tabvc.customizableViewControllers = vcs
presenter.presentViewController(tabvc,animated: true,completion: nil)

故事板模态

与故事板主题保持一致,创建正确类型的段落,分配一个标识符(即PresentModallySegue),并且上述5行成为这一行:

self.performSegueWithIdentifier("presentModallySegue",sender: self)

3.根交换

更为激烈的解决方案是在窗口级别切换根视图控制器:

let tabvc = UITabBarController()
tabvc.viewControllers = vcs
tabvc.customizableViewControllers = vcs
self.view.window!.rootViewController = tabvc

结论

或者更改您的设计以采用Tab Bar Controller作为初始视图控制器,或者以模态方式呈现Tab Bar Controller.

相关文章

UITabBarController 是 iOS 中用于管理和显示选项卡界面的一...
UITableView的重用机制避免了频繁创建和销毁单元格的开销,使...
Objective-C中,类的实例变量(instance variables)和属性(...
从内存管理的角度来看,block可以作为方法的传入参数是因为b...
WKWebView 是 iOS 开发中用于显示网页内容的组件,它是在 iO...
OC中常用的多线程编程技术: 1. NSThread NSThread是Objecti...