Edit button not displayed in UITabBarController's MoreNavigationController

后端 未结 2 736
隐瞒了意图╮
隐瞒了意图╮ 2021-01-17 19:58

A UITabBarController is being pushed onto the stack:

let presenter = presentingViewController as! UINavigationController
let tabvc = UITabBarCo         


        
相关标签:
2条回答
  • 2021-01-17 20:00

    The reason is that navigation bar of your presenter overlaps with the navigation bar of More section.

    If you don't show the navigation bar for you navigation controller, you will be able to see the Edit button again when you tap on the More tab.

    0 讨论(0)
  • 2021-01-17 20:04

    You can have both a UINavigationController and a UITabBarController ; using Storyboard helps understand the issue better, any of these solutions will work:

    1. Start out with a UITabBarController as initial view controller
    2. Use presentViewController instead of pushViewController
    3. Use a modal Storyboard segue to perform a modal presentation
    4. Swap out the rootViewController dynamically

    Initial View Controller Design

    When the Tab Bar Controller is initial View Controller, the Edit button is displayed normally.


    Pushed Design

    Another Navigation Controller is initial View Controller, using one of 5 adaptive Action Segue:

    • Show
    • Custom

    -> No Edit button, since it is in direct conflict with the parent UITableViewController.

    • Show Detail
    • Present Modally
    • Popover Presentation

    -> Edit button displayed as expected.


    Code

    1. Program Modal

    Using the exact code presented in the question, change the last line:

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

    2. Storyboard Modal

    keeping with the Storyboard theme, create a segue of the correct type, assign an identifier (i.e. presentModallySegue) and the 5 lines above become this single line:

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

    3. root Swap

    A more drastic solution involves swapping out the root view controller at the window level:

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

    Conclusion

    Either change your design to adopt the Tab Bar Controller as the initial View Controller, or present the Tab Bar Controller modally.

    0 讨论(0)
提交回复
热议问题