- Self.title = @ "Group table View";
- UITableView *tableview = [[UITableView alloc] Initwithframe:cgrectmake (0, 0, +, 568) Style:uitableviewstyleplain];
- Setting up the TableView data source proxy
- Tableview.datasource = self;
- Set up a proxy for TableView
- Tableview.delegate = self;
- [Self.view Addsubview:tableview];
- Set the head and tail views of the TableView: this sets the height of the head view, the coordinates in the X y direction are not changed, and the width cannot be modified, as is the width of the tableview.
- UIView *headerview = [[UIView alloc] Initwithframe:cgrectmake (0, 0, 320, 100)];
- Tableview.tableheaderview = Headerview;
- UIView *fooderview = [[UIView alloc] Initwithframe:cgrectmake (0, 0, 320, 40)];
- Tableview.tablefooterview = Fooderview;
16.//Setting the height of the head and tail views of a group
- Tableview.sectionheaderheight = 50;
- Tableview.sectionfooterheight = 40;
19.//Setting the height of each cell
- Tableview.rowheight = 50;
21.//the height of each group of head views
22.-(CGFloat) TableView: (uitableview*) TableView heightforheaderinsection: (nsinteger) Section;
23.//height of each set of tails
24.-(CGFloat) TableView: (uitableview*) TableView heightforfooterinsection: (nsinteger) Section;
25.//set TableView height of each row of cells
26.-(CGFloat) TableView: (uitableview*) TableView Heightforrowatindexpath: (Nsindexpath *) Indexpath;
29.//set the color of a split line
- Tableview.separatorcolor = [Uicolor Redcolor];
31.//set the style of the split line, default is Uitableviewcellseparatorstylesingleline
- Tableview.separatorstyle = Uitableviewcellseparatorstylesingleline;
33.//Setting the background view and background color
- Tableview.backgroundcolor = [Uicolor Graycolor];
- Tableview.backgroundview = [[Uiimageview alloc] initwithimage:[uiimage imagenamed:@ "bj.jpg"];
#pragma the protocol method of the Mark-uitableview.
38.//sets the number of TableView groups if not written by default creates a set of
39.-(Nsinteger) Numberofsectionsintableview: (UITableView *) TableView;
40.//set the number of cells for each group
41.-(Nsinteger) TableView: (uitableview*) TableView numberofrowsinsection: (nsinteger) Section;
42.//Create cell UITableViewCell, which is the view of each row displayed by Tablview
43.-(uitableviewcell*) TableView: (uitableview*) TableView Cellforrowatindexpath: (Nsindexpath *) Indexpath;
45.uitableviewcell*cell=[[uitableviewcell alloc] Initwithstyle:uitableviewcellstyledefault ReuseIdentifier:nil];
47.//to set headers for each group of header views
48.-(nsstring*) TableView: (uitableview*) TableView titleforheaderinsection: (nsinteger) Section;
49.//set the title of each group of trailer views
50.-(nsstring*) TableView: (uitableview*) TableView titleforfooterinsection: (nsinteger) Section;
51.//the head view of a custom group
52.-(uiview*) TableView: (uitableview*) TableView viewforheaderinsection: (nsinteger) Section;
53.//the tail view of a custom group
54.-(uiview*) TableView: (uitableview*) TableView viewforfooterinsection: (nsinteger) Section;
55.//setting the style when selecting
56.cell.selectionstyle = Uitableviewcellselectionstylegray;
57.//setting the background view after selection
Cell.selectedbackgroundview = view;
59.//Setting the secondary icon style
Cell.accessorytype = Uitableviewcellaccessorydetailbutton;
61.//Add a custom view to the Contentaview and do not add it directly to the cell
- [Cell.contentview Addsubview:titlelabel];
64.//Create a location
Nsindexpath *indexpath = [Nsindexpath indexpathforitem:1 Insection:2].
Gets the cell UITableViewCell *cell = [_tableview Cellforrowatindexpath:indexpath] at the specified location;
66.//all cell visiblecells currently displayed on the screen
67.NSArray *cellarray = [_tableview visiblecells];
68.//get all Indexpath currently displayed in the cell of the screen indexpathsforvisiblerows
69.NSArray *indexpatharray = [_tableview indexpathsforvisiblerows];
71.//scrolling to the cell at the specified location
72.//[_tableview Scrolltorowatindexpath:indexpath Atscrollposition:uitableviewscrollpositionbottom Animated:YES];
73.//refreshes the TableView, that is, to recall all implemented protocol methods
- [_tableview Reloaddata];
75.//refreshes the cell of the specified Indexpath
76.[_tableview Reloadrowsatindexpaths:@[indexpath] withrowanimation:uitableviewrowanimationautomatic];
77.//Refresh the specified section (group)
- Nsindexset *indexset = [Nsindexset indexsetwithindex:0];
- [_tableview Reloadsections:indexset Withrowanimation:uitableviewrowanimationfade];
81.//Adding an indexed view
82.-(Nsarray *) Sectionindextitlesfortableview: (UITableView *) TableView
83.{
- return @[@ "A", @ "B", @ "C", @ "D", @ "E", @ "F", @ "G", @ "H"];
85.}
86.//setting the color of indexed view text
- Tableview.sectionindexcolor = [Uicolor Whitecolor];
88.//background color of indexed views
- Tableview.sectionindexbackgroundcolor = [Uicolor Graycolor];
90.//the method that is called after clicking on the indexed view, including the title and location of the click Index position
91.-(Nsinteger) TableView: (uitableview*) TableView sectionforsectionindextitle: (NSString *) title Atindex: (Nsinteger ) index;
92.//cell will be displayed on the screen when the call
93.-(void) CollectionView: (uicollectionview*) CollectionView Willdisplaycell: (uicollectionviewcell*) cell Foritematindexpath: (Nsindexpath *) Indexpath;
94.//cell end is displayed on the screen when the call
95.-(void) CollectionView: (uicollectionview*) CollectionView Didenddisplayingcell: (uicollectionviewcell*) cell Foritematindexpath: (Nsindexpath *) Indexpath;
96.//Customizing the cell's edit mode
97.-(Uitableviewcelleditingstyle) TableView: (UITableView *) TableView Editingstyleforrowatindexpath: (Nsindexpath *) Indexpath
98.{
- return uitableviewcelleditingstyledelete;
- }
- Sets whether Tableviewcell can be moved
- -(BOOL) TableView: (uitableview*) TableView Canmoverowatindexpath: (Nsindexpath *) Indexpath;
- This method is called when the cell is moved
- -(void) TableView: (uitableview*) TableView Moverowatindexpath: (Nsindexpath *) Fromindexpath Toindexpath: (Nsindexpath *) Toindexpath {
- Swap the position of an array of two elements
- [_mutablearray ExchangeObjectAtIndex:fromIndexPath.row WithObjectAtIndex:toIndexPath.row];
- }
- Set the cell of the TableView as an editable state
- -(BOOL) TableView: (uitableview*) TableView Caneditrowatindexpath: (Nsindexpath *) Indexpath;
- Set the cell of the TableView as an editable state
- -(BOOL) TableView: (uitableview*) TableView Caneditrowatindexpath: (Nsindexpath *) Indexpath;
- Deletes the specified cell
- [TableView Deleterowsatindexpaths:@[indexpath] withrowanimation:uitableviewrowanimationfade];
- Cell Multiplexing Dequeuereusablecellwithidentifier
- static NSString *indentify = @ "Newcell";
- UITableViewCell *cell = [TableView dequeuereusablecellwithidentifier:indentify];
- if (cell = = nil) {
- Cell=[[uitableviewcell alloc] Initwithstyle:uitableviewcellstyledefault reuseidentifier:indentify];
- 1, register the ordinary class of cell
- [Self.tableview Registerclass:[uitableviewcell class] forcellreuseidentifier:@ "Newcell"];
- Newcell *cell = [TableView dequeuereusablecellwithidentifier:@ "Newcell" Forindexpath:indexpath];
- 2, Registered Xib cell
- uinib *nib = [uinib nibwithnibname:@ "Newcell" bundle:nil];
- [Self.tableview registernib:nib forcellreuseidentifier:@ "Newcell"];
- Newcell *cell = [TableView dequeuereusablecellwithidentifier:@ "Newcell" Forindexpath:indexpath];
- The story version is not allowed to register. In these three cases,
- The cell that is created by loading the Xib file should be used this way
- cell = [[[NSBundle Mainbundle] loadnibnamed:@ "Fontscell" owner:self Options:nil] lastobject];
- -(ID) Initwithstyle: (Uitableviewcellstyle) style Reuseidentifier: (NSString *) Reuseidentifier;
Cooked with TableView