Obtain the independent controller in the Storyboard and the storyboard
I recently encountered a problem with the following requirements:
Requirement: a storyboard has a single controller VC (not connected). In storyboard, drag several controls to the VC and customize a class to bind the VC, ask how to obtain this VC and display the page for setting this VC in storyboard. For example:
1. First, you must know the storyboard. First, we will introduce three storyboard methods:
1> the following method indicates that the storyboard name is obtained from a package (generally set to nil to get it from the main package ).
+ (UIStoryboard *) storyboardWithName :( NSString *) name bundle :( NSBundle *) storyboardBundleOrNil
2> This method gets the initial controller in the storyboard.
-(Id) instantiateInitialViewController
3> This method indicates that the controller is obtained through the Controller identifier. The new version of Xcode uses the Storyboard ID to indicate the identifier of a controller.
-(Id) instantiateViewControllerWithIdentifier :( NSString *) identifier;
Well, from the above three methods, many friends should know how to obtain the independent controller in the Storyboard.
2. Set the identifier of the independent VC in the storyboard, that is, the Storyboard ID, to distinguish the controller in the storyboard, as shown in
3. Call-instantiateViewControllerWithIdentifier in storyboard in the class to obtain the independent VC
ZJDuLiController * vc = [self. storyboard instantiateViewControllerWithIdentifier: @ "DuLi"]
4. push or modal output VC.
[Self. navigationController pushViewController: vc animated: YES];
The final result is as follows: