ios - Difference between instantiateViewControllerWithIdentifier and initWithNibName? -
what difference between instantiateviewcontrollerwithidentifier , initwithnibname, other former storyboard , later not?
uistoryboard *signupstory = [uistoryboard storyboardwithname:@"signupstory" bundle:[nsbundle mainbundle]]; signuploginviewcontroller *signupvc = [signupstory instantiateviewcontrollerwithidentifier:@"signupvc"];
and
signuploginviewcontroller *signupvc = [[signuploginviewcontroller alloc] initwithnibname:@"signuploginviewcontroller" bundle:[nsbundle mainbundle]];
if you've created ui using storyboards, you'll want call instantiateviewcontrollerwithidentifier
. here, identifier not part of view controller used storyboard locate view controller. storyboard handle initialization , call initwithcoder
, why need override when creating subclassed view controllers.
on other hand, if ui resides in pure .xib file - developers use initwithnibname
. does, technically, break encapsulation , there other ways it, you'll see used it's designated initializer class.
Comments
Post a Comment