问题
So I started an iOS app with the single view template. I then added a navigation controller by dragging it into the storyboard. How do I references this from my app delegate? I tried ctrl-dragging it into my AppDelegate outlet-style but that obviously doesn't work. What do I do? Instantiate one and then assign it as rootview controller?
By the end of this I'd like to use the AppDelegate to set the view to the top of the navigation controller. Thanks!
回答1:
In IB you should select the navigation controller and then click the "Is Initial View Controller" check box in the inspector -- this automatically makes that controller the root view controller of the window. In your app delegate, you can get a reference to the navigation controller with self.window.rootViewController and assign it to a property if you want.
来源:https://stackoverflow.com/questions/11979705/linking-uinavigationcontroller-in-storyboard-to-appdelegate