微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

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.

原文地址:https://www.jb51.cc/iOS/330130.html

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。

相关推荐