Summary:
The use of storyboard with the original single xib file use or some different, in the habit will be some discrepancy, here to write down the points encountered.
1. Set the first Viewcontroller to Navigationcontroller property
Normally when you create a new project, you will bring a Viewcontroller class, and storyboard will have a ready-made view bound to it, unlike in the past, there is no code in appdelegate that directly sets the view controller as the root view. If you want to set this view controller to a Navigationcontroller and push other sub-interfaces, use the following method:
In the storyboard file, a new drag out of a navigationcontroller, placed on the left side of the original view, after releasing the mouse, there will be two views, the middle of the arrow connected, now delete the view where the arrows point to, the arrows point to our original view, In the left column you can see the new Nacigationcontrollerscene root view (root view Controller) that points to our view. Then don't forget to point the arrows that represent the original interface to the Navigationcontroller we dragged out so that our view has the properties of Navigationcontroller.
2. Call the controller that is bound to the view in storyboard
We create a new view in storyboard and then associate it with a controller, and then if we want to invoke the display of this interface, we use the traditional method to create a new instance of the controller and then show that it is not possible, This will only show what the code in the controller has written, the content set in storyboard is not displayed, and most obviously the background of the view will be black. The following method should be used:
We have to find view! through storyboard. Uistoryboard *storyboard = [Uistoryboard storyboardwithname:@ "Main" bundle:nil]; Nextviewcontroller *NEXTVC = [Storyboard instantiateviewcontrollerwithidentifier:@ "Nextviewcontroller"]; [Self.navigationcontroller PUSHVIEWCONTROLLER:NEXTVC Animated:yes];
Don't forget to define the view's identifier in the view properties in storyboard, that is, the code above finds the view's credentials.
Constantly updated ...
Reprint please indicate the source, thank you
Copyright NOTICE: This article for Bo Master original article, without Bo Master permission not reproduced.
Storyboard use key records in iOS