:
. H
#import <UIKit/UIKit.h>@interface RootViewController : UIViewController<UITableViewDataSource,UITableViewDelegate>{ UITableView *mTableView;}@end
. M
-(Void) viewdidload {[Super viewdidload]; // do any additional setup after loading the view. // initialize the background color [self initbackgroundview];} # pragma-mark-Funcions-(void) initbackgroundview {mtableview = [[uitableview alloc] initwithframe: cgrectmake (0, 40,320, self. view. bounds. size. height)]; mtableview. datasource = self; mtableview. delegate = self; [self. view addsubview: mtableview];} # pragma-mark-uitableviewdelegate-(nsinteger) numberofsectionsintableview :( uitableview *) tableview {return 2;}-(nsinteger) tableview :( uitableview *) tableview numberofrowsinsection :( nsinteger) Section {If (Section = 0) {return 5;} else if (Section = 1) {return 10;} return 10;}-(cgfloat) tableview :( uitableview *) tableview heightforrowatindexpath :( nsindexpath *) indexpath {return 40;}-(uitableviewcell *) tableview :( uitableview *) tableview cellforrowatindexpath :( nsindexpath *) indexpath {static nsstring * name = @ "nearshop"; uitableviewcell * cell = [tableview labels: Name]; If (cell = nil) {Cell = [[uitableviewcell alloc] initwithstyle: uitableviewcellstyledefault reuseidentifier: Name];} cell. selectionstyle = uitableviewcellselectionstylenone; If (indexpath. section = 0) {Cell. textlabel. TEXT = @ "food";} else if (indexpath. section = 1) {Cell. textlabel. TEXT = @ "business area";} return cell;}-(uiview *) tableview :( uitableview *) tableview viewforheaderinsection :( nsinteger) Section {uiview * customview = [[uiview alloc] initwithframe: cgrectmake (0.0, 0.0, 320.0, 30.0)]; customview. backgroundcolor = [uicolor redcolor]; uilabel * headerlabel = [[uilabel alloc] initwithframe: cgrectzero]; headerlabel. backgroundcolor = [uicolor clearcolor]; headerlabel. textcolor = [uicolor blackcolor]; headerlabel. font = [uifont boldsystemfontofsize: 15]; headerlabel. frame = cgrectmake (0.0, 0.0, 320.0, 30.0); If (Section = 0) {headerlabel. TEXT = @ "popular shops";} else if (Section = 1) {headerlabel. TEXT = @ "classification";} [customview addsubview: headerlabel]; return customview ;}
One tableview and two sections