How to set the height of a UIPopoverPresentationController to be the same as your UITableView

ios, iphone, objective-c, uitableview, xcode

Solution

In the class, that you present in popover add a code:

- (void)viewDidLayoutSubviews {
    self.preferredContentSize = CGSizeMake(320, tableView.contentSize.height);
}

Problem

I'm using a UIPopoverPresentationController on my app to show a popover on my iPhone (with UIModalPresentationNone). I want the size to be dynamic with the height of the UITableView, but i can't find out how to do that. The size of the popover is the same on every device.

Original source