UITableView derived from Uiscrollview
The UITableView structure is as follows:
The background is a scrolling view, with each horizontal table called the cell (UITableViewCell)
each cell can store data or accept selected events .
When we select a cell, we can drop down the list, a new page can be launched
Select multiple cells in edit mode, you can delete batches and so on.
Member variables
1 {2 UITableView * _tablev; 3 Nsmutablearray * _dataarr; 4 Uisearchcontroller * _search; 5 Nsmutablearray * _selectcell; 6 }
UITableView Creation (written in method, can be called with self)
-(void) createtableview{ _tablev = [[UITableView alloc] Initwithframe:cgrectmake (0, 0, [UIScreen mainscreen]. Bounds.size.width, [UIScreen mainscreen].bounds.size.height-64) style:uitableviewstylegrouped]; Set UITableView style two styles /* uitableviewstyleplain, uitableviewstylegrouped * //Set Agent _tablev.delegate = self; _tablev.datasource = self; _tablev.separatorstyle = Uitableviewcellseparatorstylesingleline; [Self.view Addsubview:_tablev];}
Uitableviewdatasource protocol method
Set UITableView cell (required)
-(uitableviewcell*) TableView: (UITableView *) TableView Cellforrowatindexpath: (Nsindexpath *) indexpath{ //re-locator static NSString * str = @ "cell"; Remove the cell in the queue UITableViewCell * cell = [TableView dequeuereusablecellwithidentifier:str]; If the cell is null, a new cell if (!cell) { cell = [[UITableViewCell alloc] Initwithstyle is created: Uitableviewcellstyledefault reuseidentifier:str]; } Cell.textLabel.text = _dataarr[indexpath.row]; return cell;}
Set the number of cells for the UITableView partition (section) (required)
-(Nsinteger) TableView: (UITableView *) TableView numberofrowsinsection: (nsinteger) section{ //return [[_dataarr Objectatindex:section] count]; return _dataarr.count;}
Set the number of UITableView partitions (sections) (optional)
-(Nsinteger) Numberofsectionsintableview: (UITableView *) TableView; Default is 1 if not implemented{ return 1;}
Set UITableView title header (optional)
-(NSString *) TableView: (UITableView *) TableView titleforheaderinsection: (nsinteger) section{ return @ "title";}
Set UITableView title footer (optional)
-(NSString *) TableView: (UITableView *) TableView titleforfooterinsection: (nsinteger) section{ return @ "footer Title ";}
Set UITableView title footer (optional)
IOS UI Learning UITableView-----Uitableviewdatasource