Summary of four ways to create a cell
1, pure code create cell mode
1 Delete uiviewcontroller, build Uitableviewcontroller in storyboard to create a uitableviewcontroller corresponding to it, the cell deleted
2 Build a UITableViewCell inside with initWithFrame, the last frame is deleted, replaced by style, according to the enumeration hit
3 where cell is built in Tableviewcontroler
Tableviewcell *cell=[tableview dequeuereuseablewithidentifier:@ "Cell"]; Note that this is a
if (!cell) =[uitableviewcell alloc]initwithstyle:uitableviewcelldefault reuseidentifier:@ "Cell"];
4 after setting the cell space in UITableViewCell init
[Self.contentview Addsubview:self.view];
2, create cell with storyboard
1, associating Storyboard's tableviewcontroller with Tableviewcontroller. Cell settings Identifier "cell"
2. Drag a variety of controls into the cell that you want to join
3, establish Tableviewcell to associate the cell in storyboard with the Tableviewcell, and drag the control property into the. h
4, select two when Uitableviewcontroller create cell (including Indexpath)
UITableViewCell *cell=[tableview dequeuereusecellwithidentifier:@ "cell" Forindexpath:index path];
[Email protected] "111";
5, according to the object-oriented thinking, so the assignment should be carried out in Tableviewcell, the point-in-time method
-(void) layoutsubviews{the control operation here};
3, create cell with Xib
1, create Tableviewcontroller,storyboard in the associated delete cell
2, create a Tableviewcell with its xib, associate, drag the control into the Xib, and associate the property with the Tableviewcel.h
Within the cell method in 3.tableviewcontroller
Tableviewcell *cell=[[nsbundle mainbundle]loadnibname: "Tableviewcontroller" owner:self Options:nil] Firstobjects]; Xib is equivalent to an array
4. You can set the control directly in the cell method
4, Static cell
1. Delete the Set cell or row number of the Uitableviewcontroller associated with the storyboard
2. Change the content of TableView to static Cells in storyboard
3. Set it directly in the storyboard to
Create cell Mode summary 0919 Lan Yi