Basic data usage for iOS UITableView

Source: Internet
Author: User

In the viewcontroller.m file:

viewcontroller.m//002 uses uitable////Created by Feng Wang on 8/16/15.//Copyright (c) smartcost. All rights reserved.//#import "ViewController.h" @interface Viewcontroller () <UITableViewDataSource> @property ( Weak, nonatomic) Iboutlet UITableView *tableview; @end @implementation viewcontroller/* 1. Set data source object 2 for UITableView. Let the data source object comply with Uitableviewdatasource Protocol 3. The method of implementing the Uitableviewdatasource protocol in the data source object (3 methods are generally implemented) */-(void) Viewdidload {[Super    Viewdidload];    Additional setup after loading the view, typically from a nib.    There are two ways to set up a data object//1. The way the code self.tableview.dataSource = self;    2. Drag the line way}-(void) didreceivememorywarning {[Super didreceivememorywarning]; Dispose of any resources the can be recreated.}    Tell UITableView to show the unit//This method can not be implemented, do not implement the default display 1 groups-(Nsinteger) Numberofsectionsintableview: (UITableView *) tableview{ return 1;} 2. Tell UITableView to display several rows of data per group-(Nsinteger) TableView: (UITableView *) TableView numberofrowsinsection: (nsinteger) Section {return 2;} 3. Tell UITabLView What cell content is displayed for each row of each group-(UITableViewCell *) TableView: (UITableView *) TableView Cellforrowatindexpath: (Nsindexpath *)  indexpath{//Create a Cell object and return UITableViewCell *cell = [[UITableViewCell alloc] Initwithstyle:uitableviewcellstyledefault    Reuseidentifier:nil];    Specify the data for the cell Cell.textLabel.text = @ "Hello"; return cell;} @end


Copyright NOTICE: This article for Bo Master original article, without Bo Master permission not reproduced.

Basic data usage for iOS UITableView

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.