UITableView is what we use to show the data, his use is very extensive, but also the most used controls, let's look at his simple use.
Uitabelview itself with Uiscrollview, so more data, he is automatic scrolling.
To display data in Uitabelview, you must have a data source, that is, let Viewcontroller implement the <UITableviewDataSource> protocol.
@interface Viewcontroller () <UITableViewDataSource>
1. You can use the connection method
2.self.tableview.delegate = self;
The following three methods are then implemented in this Protocol.
1. Returns a total of several sets of data.
-(Nsinteger) Numberofsectionsintableview: (UITableView *) TableView { return 1;}
2. Returns a few rows per group
-(Nsinteger) TableView: (UITableView *) TableView numberofrowsinsection: (nsinteger) Section { return Self.heros.count;}
3. Show the data for each row
-(UITableViewCell *) TableView: (UITableView *) TableView Cellforrowatindexpath: (Nsindexpath *) Indexpath { static NSString *id = @ "Hero"; UITableViewCell *cell = [TableView dequeuereusablecellwithidentifier:id]; if (cell = = nil) { cell = [[UITableViewCell alloc] Initwithstyle:uitableviewcellstylesubtitle reuseidentifier:id];< c6/>} Hero *hero = Self.heros[indexpath.row]; Cell.textLabel.text = Hero.name; Cell.detailTextLabel.text = Hero.intro; Cell.imageView.image = [UIImage ImageNamed:hero.icon]; return cell;}
This is uitableview simple to use!
Use of the "iOS development" UITableView