First, you can create a uiview object using the IB and encoding methods.
1. IB (interface builder) method: load a view from the NIB file. The initwithcoder method of the view object is called, and the awakefromnib method is called.
Cmbutton * button = [[[nsbundle mainbundle] loadnibnamed: @ "cmviewcontroller" Owner: Self options: Nil] lastobject]; // This statement calls the initwithcoder and awakefromnib methods of the button.
When "cmviewcontroller. Nib" is loaded for the first time, the initwithcoder and awakefromnib messages are sent to all objects in the NIB file, that is, the initwithcoder and awakefromnib methods of each object are called once.
2. encoding method. When you create a view object using code, the initwithframe method of the object is called.
Cmbutton * button = [[cmbutton alloc] init]; // The initwithframe method of the button is called.
Initwithcoder, awakefromnib, initwithframe