A UITabBarController
is being pushed onto the stack:
let presenter = presentingViewController as! UINavigationController
let tabvc = UITabBarCo
You can have both a UINavigationController
and a UITabBarController
; using Storyboard
helps understand the issue better, any of these solutions will work:
UITabBarController
as initial view controllerpresentViewController
instead of pushViewController
Storyboard
segue to perform a modal presentationrootViewController
dynamicallyWhen the Tab Bar Controller is initial View Controller, the Edit button is displayed normally.
Another Navigation Controller is initial View Controller, using one of 5 adaptive Action Segue:
-> No Edit button, since it is in direct conflict with the parent UITableViewController
.
-> Edit button displayed as expected.
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
Either change your design to adopt the Tab Bar Controller as the initial View Controller, or present the Tab Bar Controller modally.