Problem
(UIView *) TableView: (uitableview *) TableView viewforheaderinsection: (nsinteger) Section The section in the method appears to start at 1 instead of from 0
Ideas
Although the program is set up Self . TableView. Sectionheaderheight =20
It's still not working. The section in Viewforheaderinsection always starts at 1.
So I found that if you use the method:
-(cgfloat) TableView: (uitableview *) TableView heightforheaderinsection: (nsinteger) Section
{
return ;
}
It's starting from 0.
Nima Jing A new feature of IOS7, in fact self. TableView. Sectionheaderheight =20 This efficiency is much faster than the method. If there are no special needs, let's set the properties directly.
-(CGFloat) TableView: (UITableView *) TableView heightforheaderinsection: (nsinteger) section{return +;}-(UIView *) TableView: (UITableView *) TableView viewforheaderinsection: (nsinteger) section{UIView*headerview = [[UIView alloc] Initwithframe:cgrectmake (0,0, TableView.frame.size.width, +)]; UILabel*label = [[UILabel alloc] Initwithframe:cgrectmake ( -,Ten, TableView.frame.size.width, -)]; Label.font= [Uifont systemfontofsize:16.0f];//font size of UilabelLabel.numberoflines =0;//This property must be defined, otherwise uilabel will not wrap.Label.textcolor = Cr_rgbcolor ( the, the, the); Label.textalignment= Nstextalignmentleft;//Text Alignment[Label Setbackgroundcolor:[uicolor Clearcolor]; Label.text=Self.sectiontitles[section]; [Headerview Setbackgroundcolor:[uicolor Clearcolor]; [Headerview Addsubview:label]; returnHeaderview;}-(UIView *) TableView: (UITableView *) TableView viewforfooterinsection: (nsinteger) section{return[[Crcustomfooter alloc] init];}- (void) TableView: (UITableView *) TableView Didselectrowatindexpath: (Nsindexpath *) indexpath{nsuinteger section=indexpath.section; Nsuinteger Row=Indexpath.row; if(Section = =1){ if(Row = =0) {[Self recommendtofriends]; [TableView Deselectrowatindexpath:indexpath Animated:yes]; }Else if(Row = =1) {[Self sendfeedback]; [TableView Deselectrowatindexpath:indexpath Animated:yes]; }Else if(Row = =2) {[Self rateapp]; [TableView Deselectrowatindexpath:indexpath Animated:yes]; }Else{ } }}