-Establishment of UITableView
datatable = [[UITableView alloc] Initwithframe:cgrectmake (0, 0, +, 420)]; [datatable setdelegate:self];& nbsp [DataTable Setdatasource:self]; [self.view addsubview:datatable]; [datatable release]; II, UITableView Each method Description //section Total-(Nsarray *) Sectionindextitlesfortableview: (UITableView *) tableview{ return titledata;} //section titles//the title displayed for each section-(NSString *) TableView: (UITableView *) TableView titleforheaderinsection: ( Nsinteger) Section{ return @ "";} //specifies how many partitions (section), the default is 1-(Nsinteger) Numberofsectionsintableview: (UITableView *) TableView { return 4;} //Specifies how many rows are in each partition and defaults to 1-(Nsinteger) TableView: (UITableView *) TableView numberofrowsinsection: (Nsinteger) section{ } //Draw cell-(UITableViewCell *) TableView: (UITableView *) TableView Cellforrowatindexpath: (Nsindexpath *) Indexpath {static NSString *simpletableidentifier = @ "Simpletableidentifier"; UITableViewCell *cell = [TableView Dequeuereusablecellwithidentifier: Sim pletableidentifier]; if (cell = = nil) { cell = [[Uitableviewcel L Alloc] initwithstyle:uitableviewcellstyledefault &N Bsp Reuseidentifier:simpletableidentifier] autorelease];  ;} cell.imageview.image=image;//picture when cell is not selected cell.imageview.highlightedimage=highlightimage;//the picture after cell is selected cell.text=//..... return Cell;} //Line Indent-(Nsinteger) TableView: (UITableView *) TableView Indentationlevelforrowatindexpath: (Nsindexpath *) Indexpath{ nsuinteger row = [Indexpath row]; return row;} //Change the height of the row-(cgfloat) TableView: (UITableView *) TableView Heightforrowatindexpath: (Nsindexpath *) indexpath{ return 40;} //positioning [topicstable SETCONTENTOFFSET:CGPOintmake (0, Promisenum * + Chapter *)]; //returns the currently selected Cellnsindexpath *ip = [Nsindexpath indexpathforrow:row inSectio N:section]; [Topicstable selectrowatindexpath:ip Animated:yes Scrollposition:uitableviewscrollpositionnone]; [tableview setseparatorstyle:uitableviewcellselectionstylenone]; //selected cell response event-(void) TableView: (UITableView *) TableView Didselectrowatindexpath: (Nsindexpath *) Indexpath{ [tableview Deselectrowatindexpath:indexpath animated:yes];//the selected inverse color disappears immediately} //the selected row (prevents the first row from being selected)-(Nsindexpath *) TableView: (UITableView *) TableView Willselectrowatindexpath: (Nsindexpath *) indexpath{ nsuinteger row = [Indexpath row]; if (row = = 0) return nil; return Indexpath;} //scrub Cell appears del button-(BOOL) TableView: (UITableView *) TableView Caneditrowatindexpath: (Nsindexpath *) Indexpath {} //Edit State-(void) TableView: (UITableView *) TableView Commiteditingstyle: (UITableViewCellEditingstyle) Editingstyleforrowatindexpath: (Nsindexpath *) indexpath{}[topicstable setContentSize:CGSizeMake (0, Controller.promisenum * 44) Add an index table to the right of];//-(Nsarray *) Sectionindextitlesfortableview: (UITableView *) tableview{}// Returns section header Content-(NSString *) TableView: (UITableView *) TableView titleforheaderinsection: (Nsinteger) section{}// Custom Scrub del button Content-(NSString *) TableView: (UITableView *) Tableviewtitlefordeleteconfirmationbuttonforrowatindexpath: ( Nsindexpath *) indexpath//jumps to the referring row or Section[tableview Scrolltorowatindexpath:[nsindexpath indexpathforrow:0 INSECTION:0] Atscrollposition:uitableviewscrollpositionbottom Animated:no]; three, on the UITableViewCell to establish the Uilable multi-line display-( UITableViewCell *) TableView: (UITableView *) TableView Cellforrowatindexpath: (Nsindexpath *) Indexpath { static nsstring *cellidentifier = @ "Cell"; uitableviewcell *cell = [TableView dequeuereusablecellwithidentifier:cellidentifier] ; if (cell = nil) { &nbsP cell = [[[UITableViewCell alloc] Initwithframe:cgrectzero Reuseidentifier:cellidentifier] autorelease]; uilabel *datalabel = [[UILabel alloc] Initwithframe:cgrectmake (0, +/-)]; [datalabel settag:100 ]; datalabel.autoresizingmask = Uiviewautoresizingflexiblewidth | Uiviewautoresizingflexibleheight; [cell.contentview Addsubview:datalabel]; [datalabel Release]; } uilabel *datalabel = (UILabel *) [Cell.contentview Viewwithtag:100]; [datalabel Setfont:[uifont boldsystemfontofsize:18]]; datalabel.text = [data. DataArray objectatindex:indexpath.row]; cell.accessorytype = Uitableviewcellaccessorydisclosureindicator; return Cell;} Color when cell is selected typedef enum { UITableViewCellSelectionStyleNone, uitableviewcellselectionstyleblue, uitableviewcellselectionstylegray} Uitableviewcellselectionstyle //cell right button format typedef enum { uitableviewcellaccessorynone, //don ' t show an Y accessory view uitableviewcellaccessorydisclosureindicator, //regular chevron. Doesn ' t track uitableviewcellaccessorydetaildisclosurebutton,//blue button W/chevron. tracks uitableviewcellaccessorycheckmark //Checkmark . Doesn ' t track} uitableviewcellaccessorytype//whether to add line typedef enum { uitableviewcellseparatorstylenone, uitableviewcellseparatorstylesingleline} uitableviewcellseparatorstyle//Change line Line Color Tableview.separatorcolor = [Uicolor Bluecolor];
iOS Development--tableview detailed explanation