Apple officially gave me 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, Talk about the solution I'm developing: (two at the moment)
The first method: When initializing the TableView, set the TableView style to Uitableviewstyleplain, overriding the TableView scrollviewdidscroll: (Uiscrollview *) ScrollView
Detail the code is as follows:
UITableView *tableview = [[UITableView alloc] Initwithframe:cgrectmake (0, 0, Self.view.frame.size.width, Self.view.frame.size.height) style:uitableviewstyleplain];</span>
-(void) Scrollviewdidscroll: (Uiscrollview *) scrollview{ cgfloat sectionheaderheight = 10;//Set your 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>
Another way: when initializing TableView , set the TableView style to uitableviewstylegrouped, at the same time in the UITableView proxy method, the height of the Footerview is set to a small (without leaving visible gaps) of the 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)
Detailed code:
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;}
"IOS" TableView Footerview does not stay on the bottom of the TableView with cell scrolling