////VIEWCONTROLLER.M//zqrtableviewtest////Created by Zzqqrr on 17/8/24.//Copyright (c) 2017 zzqqrr. All rights reserved.//#import "ViewController.h"@interfaceViewcontroller () <UITableViewDataSource>@property (weak,nonatomic) iboutlet UITableView*TableView;@end@implementationViewcontroller- (void) viewdidload {[Super viewdidload]; Self.tableView.dataSource=Self ;}/** Set up group*/-(Nsinteger) Numberofsectionsintableview: (UITableView *) tableview{return 3;}-(Nsinteger) TableView: (UITableView *) TableView numberofrowsinsection: (nsinteger) section{if(section==0)//First Group { return 1; } Else if(section==1)//Second group { return 2; } Else {//Third Group return 3; }}-(UITableViewCell *) TableView: (UITableView *) TableView Cellforrowatindexpath: (Nsindexpath *) indexpath{UITableViewCell*cell=[[UITableViewCell alloc] Initwithstyle:uitableviewcellstyledefault Reuseidentifier:nil]; if(indexpath.section==0) {Cell.textLabel.text=@"First group first row"; }Else if(indexpath.section==1) { if(indexpath.row==0) {Cell.textLabel.text=@"first row of the second group"; }Else if(indexpath.row==1) {Cell.textLabel.text=@"Second group second row"; } } Else{ if(indexpath.row==0) {Cell.textLabel.text=@"The first line of the third group"; }Else if(indexpath.row==1) {Cell.textLabel.text=@"Third group, second row"; }Else{Cell.textLabel.text=@"Third group, third row"; } } returncell;}@end
iOS primary knowledge uitableview and simple usage