The Apple method provides me with TableView Footerview and Headerview to stay at the top of the very good effect, sometimes we do not need these footerview and Headerview stay at the bottom or the upper, now take Footerview as an example, Tell me about the solution I'm developing: (at present two kinds of)
The first method is to set the TableView style to Uitableviewstyleplain when initializing TableView, while overriding the TableView scrollviewdidscroll: (Uiscrollview *) ScrollView
specific The code is as follows:
<span style= "FONT-SIZE:14PX;" >uitableview *tableview = [[UITableView alloc] Initwithframe:cgrectmake (0, 0, Self.view.frame.size.width, Self.view.frame.size.height) style:uitableviewstyleplain];</span>
<span style= "FONT-SIZE:14PX;" >-(void) Scrollviewdidscroll: (Uiscrollview *) scrollview{ cgfloat sectionheaderheight = 10;//Set you footer height if (scrollview.contentoffset.y<=sectionheaderheight&&scrollview.contentoffset.y>=0) { Scrollview.contentinset = Uiedgeinsetsmake (-scrollview.contentoffset.y, 0, 0, 0); } else if (scrollview.contentoffset.y>=sectionheaderheight) { Scrollview.contentinset = Uiedgeinsetsmake (- Sectionheaderheight, 0, 0, 0); } } </span>
The second method: when initializing the TableView , set the TableView style to uitableviewstylegrouped, at the same time, in the UITableView proxy method, set the height of the footerview to a very small (no visible void) value, just fine! (note here, can not be set to 0, no tableview will think you do not set the height will take the default height)
Specific code:
<span style= "FONT-SIZE:14PX;" >uitableview *tableview = [[UITableView alloc] Initwithframe:cgrectmake (0, 0, Self.view.frame.size.width, self.view.frame.size.height) style:uitableviewstylegrouped]; Tableview.delegate = self; Tableview.datasource = self;</span>
-(CGFloat) TableView: (UITableView *) TableView heightforheaderinsection: (nsinteger) section{ return 0.0001f;}
Copyright NOTICE: This article for Bo Master original article, without Bo Master permission not reproduced.
"IOS" TableView Footerview does not stay on the bottom of the TableView with cell scrolling