The Address book implemented in storyboard now replaces the code with the interface
Add a new Xib file
1 #pragmaMark creates a line with xib and adds text and avatar2-(UIView *) Createrowview3 {4 //0. Load the Rowview file, create an objects array to wrap all controls in order to return xib = The nib app automatically generates XIB files when packaged5Nsarray *views = [[NSBundle mainbundle] loadnibnamed:@"Rowview"owner:self Options:nil];6 //1. Remove a line view7UIView *rowviews = views[0];8 //2. Set the Avatar9UIButton *imgbtn = (UIButton *) [Rowviews Viewwithtag:1];TenNSString *names = [NSString stringWithFormat:@"0%d.jpg", Arc4random_uniform (9)]; One //2.1 Set Avatar button background graph get avatar randomly A [imgbtn setimage:[uiimage imagenamed:names] forstate:uicontrolstatenormal]; - //2.2 Add Avatar Click to listen - [imgbtn addtarget:self Action: @selector (Iconclick:) forcontrolevents:uicontroleventtouchupinside]; the //3. Settings Description -UILabel *lab = (UILabel *) [Rowviews Viewwithtag:2]; - //3.1 Random access to descriptive information -Lab.text =_allnames[arc4random_uniform ((int) _allnames.count)]; + //4. Set the Delete button -UIButton *delbtn = (UIButton *) [Rowviews Viewwithtag:3]; + //4.1 Add Delete Click to listen A [delbtn addtarget:self Action: @selector (Delclick:) forcontrolevents:uicontroleventtouchupinside]; at returnrowviews; -}
The second way to remove the added listener is to connect (to change the controller environment to be consistent)
Change the owner file associated class file from the Xib form the name matches the name of the storyboard.h.
To change the load resolution Xib load method, change the Owner property to the current form: self
1 // 0. Load the Rowview file, create an objects array to wrap all controls in order to return xib = The nib app automatically generates XIB files when packaged 2 Nsarray *views = [[NSBundle mainbundle] loadnibnamed:@ "rowview" owner: Self Options:nil];
Contacts xib files and storyboard mixed programming