Table control
#import "HMViewController.h"@interfaceHmviewcontroller () <UITableViewDataSource>@property (Weak, nonatomic) Iboutlet UITableView*TableView;@end@implementationHmviewcontroller#pragmaMark-Data Source methods//if not implemented, the default is 1-(Nsinteger) Numberofsectionsintableview: (UITableView *) tableview{return 2;}//The total number of data in each grouping//sction: Number of groupings-(Nsinteger) TableView: (UITableView *) TableView numberofrowsinsection: (nsinteger) section{if(Section = =0) { //No. 0 Group return 5; } Else { return -; }}//tells the table control the details of cell cells in each row//Indexpath//@property (nonatomic,readonly) Nsinteger section; Grouping//@property (nonatomic,readonly) Nsinteger row; Line-(UITableViewCell *) TableView: (UITableView *) TableView Cellforrowatindexpath: (Nsindexpath *) indexpath{//when instantiating Tableviewcell, use the Initwithstyle method to instantiateUITableViewCell *cell =[[UITableViewCell alloc] Initwithstyle:uitableviewcellstyledefault Reuseidentifier:nil]; Cell.textLabel.text= [NSString stringWithFormat:@"Dark Horse student%02d period-%04d", Indexpath.section, Indexpath.row]; returncell;}//returns the grouped caption text-(NSString *) TableView: (UITableView *) TableView titleforheaderinsection: (nsinteger) section{return[NSString stringWithFormat:@"Dark Horse%02d period", section];}-(NSString *) TableView: (UITableView *) TableView titleforfooterinsection: (nsinteger) section{if(Section = =0) { return @"It's too bull."; } Else { return @"A bull's fork is shining brightly"; }}@end
iOS Seventh day (basic usage of 1:uitableview)