Create cell Mode summary 0919 Lan Yi

Source: Internet
Author: User

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

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.