ios - How to vertical align (center) the content of UITableView? -


i want center content of uitableview contains headerview , footerview created @ storyboard, , uitableviewcells. how can achieve this?

here i'm trying implement solve problem not work.

- (void)viewwillappear:(bool)animated {     [super viewwillappear:animated];      cgfloat height = self.tableview.frameheight - self.navigationcontroller.navigationbar.frameheight - [uiapplication sharedapplication].statusbarframe.size.height - (self.rowcount * self.rowheight);     self.tableview.tableheaderview.frameheight = height / 2.0; } 

so subtracted height of navigationbar & statusbar , cells' height tableview's height height of empty area. height if empty area, divided 2 footer , header's view.

in viewwillappear , in didrotatefrominterfaceorientation functions :

cgfloat headerheight = (self.view.frame.size.height - (row_height * [self.tableview numberofrowsinsection:0]))) / 2;  self.tableview.contentinset = uiedgeinsetsmake(headerheight, 0, -headerheight, 0); 

this solve problem.


Comments

Popular posts from this blog

qt - Using float or double for own QML classes -

Create Outlook appointment via C# .Net -

ios - Swift Array Resetting Itself -