Pre iOS7 I would use this bit of code to caclulate how big a UITableView would be and then set its tableView.contentSizeForViewInPopover:
(it is a class method to my catagory of UIPopoverController
):
+(CGFloat)createContentHeighForTableViewController:(UITableViewController *)viewController {
CGFloat tableViewHeight = 0;
for (int i = 0; i < [viewController.tableView numberOfSections]; i++)
{
CGRect sectionRect = [viewController.tableView rectForSection:i];
tableViewHeight += sectionRect.size.height;
}
if (tableViewHeight > POPOVER_SIZE.height){
return POPOVER_SIZE.height;
}
else {
return tableViewHeight;
}
}
It wasn't perfect, but would work reasonably well:
When I scroll it down, it pulls the tableView
back up and it rests where it is in the picture.
Here is why I said my code worked pretty well:
This is the result of scrolling up and it resting with some of the tableview
slightly out of the view.
With the move to iOS7 and the same code, this is the result:
That is the default w/out any scrolling.
Its clear that my content size is too small. How can I better calculate the size of the tableView?