![](/img/trans.png)
[英]Change 'edit' Button Color from moreNavigationController of UITabBarController?
[英]Edit button not displayed in UITabBarController's MoreNavigationController
正在將UITabBarController
壓入堆棧:
let presenter = presentingViewController as! UINavigationController
let tabvc = UITabBarController()
tabvc.viewControllers = vcs
tabvc.customizableViewControllers = vcs
presenter.pushViewController(tabvc, animated: true)
一旦顯示,正確顯示更多選項卡按鈕,但重新排列選項卡欄的編輯按鈕不會。 根據MoreNavigationController上的文檔 :
標准更多項的界面包括一個“編輯”按鈕,允許用戶重新配置標簽欄。 默認情況下,允許用戶重新排列選項卡欄上的所有項目。 但是,如果您不希望用戶修改某些項,則可以從customizableViewControllers屬性中的數組中刪除相應的視圖控制器。
我的猜測是標簽欄不適合在導航控制器中使用。 關於帶回編輯按鈕的任何想法?
你可以同時擁有UINavigationController
和UITabBarController
; 使用Storyboard
有助於更好地理解問題,任何這些解決方案都可以使用:
UITabBarController
作為初始視圖控制器 presentViewController
而不是pushViewController
Storyboard
segue執行模態演示 rootViewController
標簽欄控制器是初始視圖控制器時 ,正常顯示編輯按鈕。
另一個導航控制器是 初始視圖控制器 ,使用5個自適應動作Segue之一:
- > No Edit按鈕,因為它與父UITableViewController
直接沖突。
- >按預期顯示編輯按鈕。
1.程序模式
使用問題中提供的確切代碼,更改最后一行:
let presenter = presentingViewController as! UINavigationController
let tabvc = UITabBarController()
tabvc.viewControllers = vcs
tabvc.customizableViewControllers = vcs
presenter.presentViewController(tabvc, animated: true, completion: nil)
2.故事板模態
保持Storyboard
主題,創建一個正確類型的segue,分配一個標識符(即presentModallySegue ),上面的5行成為這一行 :
self.performSegueWithIdentifier("presentModallySegue", sender: self)
3.根交換
更激烈的解決方案涉及在window
級別交換根視圖控制器:
let tabvc = UITabBarController()
tabvc.viewControllers = vcs
tabvc.customizableViewControllers = vcs
self.view.window!.rootViewController = tabvc
更改設計以采用Tab Bar Controller作為初始View Controller ,或以模態方式顯示Tab Bar Controller。
原因是您的演示者的導航欄與“ 更多”部分的導航欄重疊。
如果您沒有顯示導航控制器的導航欄,則在點擊“ 更多”選項卡時,您將能夠再次看到“ 編輯”按鈕。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.