First, Initwithnibname This method is created in the Controller's class in IB, but it is used when instantiating a controller through Xcode.
Second, Initwithcoder is called when a class is created in IB but is instantiated in XOCDE. For example, create a controller's nib file with IB and then in Xcode Initwithnibname to instantiate the controller, the controller's initwithcoder will be called. Or a view nib file that is called when the method is created Initwithcoder
Third, awakefromnib
When the. nib file is loaded, a awakefromnib message is sent to each object in the. nib file, and each object can define its own awakefromnib function to respond to the message and perform some necessary actions. That is, the awakefromnib is executed when the view object is created from the nib file
Iv. the differences and linkages between initwithnibname and loadnibnamed:
About the difference and connection between Initwithnibname and loadnibnamed. I think I'm a little confused about what I'm going to do with the two. Actually figuring out the difference between them will not be so confused. Because these two methods are not tarred with at all.
Since it is to illustrate these 2 methods, then focus on the difference.
But the first step is to wordy, their connection: You can use this method to load the user interface (Xib file) into our code, so that you can manipulate the loaded (Xib) object to operate the Xib file content.
The following goes into the topic, talking about the difference:
1. Initwithnibname Method of Showviewcontroller
Showviewcontroller * ShowMessage = [[Showviewcontroller alloc]
initwithnibname:@ "Showviewcontroller" bundle:nil];
Self.showviewcontroller = ShowMessage;
[ShowMessage release];
The Loadnibnamed method of 2.VideoCellController
Nsarray * nib = [[NSBundle mainbundle] loadnibnamed:@ "Save3viewcontroller"
Owner:self Options:nil];
Summarize:
Just looking at their initialization, it may feel the same. But if, open to see the relationship between Xib, only to realize that their integration classes are different.
1. Initwithnibname to load the class of xib that we have defined for the View Controller class
2. Different loading modes
Initwithnibname method: Is deferred loading, the control on this view is nil, only to need to display, will not nil
Loadnibnamed method: Instant loading, each element in the Xib object loaded with this method already exists.
(Carefully understand this rule: when using loadNibNamed:owner:options:, the File's owner should is NSObject, the main view should be your class Type, and all outlets should is hooked up to the view, not the File ' s Owner.)
The difference between the five, Initwithcoder and initWithFrame
Initwithoder is called when an object is loaded from the nib file, such as when your view is from the nib, then this function of the view is called. (called by the framework)
initWithFrame (is called by the user to initialize the object)
The Init method that gets used depends on how the view is created. It can be explicitly created using initwithframe or it can be created by loading a nib. In this case, the Initwithcoder method gets called when the view was loaded from the nib. There is other Init methods for subclasses (like Uitableviewcontroller had Initwithstyle), so you had to be sure which O NE is being called.
Self.showviewcontroller = [nib Lastobject];
[NIB objectatindex:0];
Excerpt from: Baidu with you in the team Baidu answer
Ios_init Related Information