问题
I am creating an iOS app which consists of 2 storyboards.
This is the second one:
I am targeting iOS 7 so I cant use storyboard references. Switch between storyboards is handled programmatically
Using this code:
let viewController:UIViewController = UIStoryboard(name: "Warnings", bundle: nil).instantiateViewControllerWithIdentifier("WarningsInitialView") as UIViewController
self.presentViewController(viewController, animated: true, completion: nil)
I can get to the second storyboard using this. However as you can see second storyboard consists of Tab Controller and I want (on both tabs) back button which will point to the main (previous) storyboard. How should I achieve this?
I have tried using this code:
AvalanchesBackButton.leftBarButtonItem = UIBarButtonItem (title: "< Spät", style: UIBarButtonItemStyle.Plain, target: self, action: "backButtonClicked")
I will be able to achieve what I want by using different view controllers for both views and hardcoding it. But is there a way to do it more cleanly? Like implement a back button on container Tab Controller which will point to previous storyboard?
Thanks in advance
回答1:
Is your previous ViewController embedded into a Navigation controller? because "pushing" the view controller automatically adds the back button.
self.navigationController?.pushViewController(viewController: UIViewController, animated: Bool)
来源:https://stackoverflow.com/questions/35046445/back-button-to-another-storyboard