A similar personal center can be implemented using UITABLEVIEWL.
Final effect
Directly on the code
First make
Uiviewcontroller
Implementation protocol
Uitableviewdatasource , uitableviewdelegate
Create two properties
UITableView *personaltableview;
Nsarray *datasource;
@interface Userinfoviewcontroller () <uitableviewdatasource,uitableviewdelegate>{ UITableView * Personaltableview; Nsarray *datasource; }
Initialization
Personaltableview=[[uitableview alloc]initwithframe:cgrectmake (0, 44+20, Screen_width, SCREEN_HEIGHT-20-44-49) Style:uitableviewstylegrouped]; [Self.view Addsubview:personaltableview]; personaltableview.delegate=self; personaltableview.datasource=self; Personaltableview.bounces=no; Personaltableview.showsverticalscrollindicator = no;//does not display the right slider personaltableview.separatorstyle= uitableviewcellseparatorstylesingleline;//Split Line [email protected][@ "My share", @ "password management", @ "User Agreement" @ "about"];
Implement a few proxies
#pragma mark tableviewdelegate-(Nsinteger) Numberofsectionsintableview: (UITableView *) tableview{//number of groups that is, section re Turn 3;} Set the number of TableView under each grouping-(Nsinteger) TableView: (UITableView *) TableView numberofrowsinsection: (Nsinteger) section{if ( section==0) {return 1; }else if (section==1) {return datasource.count; }else{return 1; }}//blank height reserved on top of each group-(cgfloat) TableView: (UITableView *) TableView heightforheaderinsection: (nsinteger) section{return 20;} Blank height reserved below each group-(cgfloat) TableView: (UITableView *) TableView heightforfooterinsection: (Nsinteger) section{if ( section==2) {return 40; } return 20;} The corresponding TableView height in each packet-(cgfloat) TableView: (UITableView *) TableView Heightforrowatindexpath: (Nsindexpath *) indexpath{if (indexpath.section==0) {return 80; } return 40;} Set the cell corresponding to each row (UITableViewCell *) TableView: (UITableView *) TableView Cellforrowatindexpath: (Nsindexpath *) indexpath{Static NSString *[email protEcted] "cell"; UITableViewCell *cell=[tableview Dequeuereusablecellwithidentifier:identifer]; if (cell==nil) {Cell=[[uitableviewcell alloc]initwithstyle:uitableviewcellstyledefault reuseIdentifier:identifer]; } if (indexpath.section==0) {Cell=[[uitableviewcell Alloc]initwithstyle:uitableviewcellstyledefault Reu seidentifier:@ "UserInfo"]; Uiimageview *imageview=[[uiimageview Alloc]initwithframe:cgrectmake (12, 0, 80, 80)]; Imageview.image=[uiimage imagenamed:@ "Usericon.png"]; [Cell.contentview Addsubview:imageview]; UILabel *namelabel=[[uilabel alloc]initwithframe:cgrectmake (100, 0, 60, 80)]; [email protected] "Li Chen"; [Cell.contentview Addsubview:namelabel]; }else if (indexpath.section==1) {Cell.textlabel.text=[datasource ObjectAtIndex:indexPath.row]; }else{[email protected] "Exit login"; Cell.textlabel.textalignment=nstextalignmentcenter; } return cell;
So far the whole interface has been basically implemented
If there is a problem can add QQ discussion
Apple Development Group: 414319235 Welcome to Join
UiviewcontrollerUitableviewdatasource,uitableviewdelegate
IOS uses TableView to implement a personal hub list