开发者

When displaying a UITableView in a UIPopoverViewController, how do you automatically resize the height?

开发者 https://www.devze.com 2023-04-01 08:14 出处:网络
I\'m presenting a UIPopoverViewController with a UINavigationController with a UITableViewController inside of it. The tableview only has four rows, but the height of the popover is as big as the scre

I'm presenting a UIPopoverViewController with a UINavigationController with a UITableViewController inside of it. The tableview only has four rows, but the height of the popover is as big as the screen allows.

What is the proper way to limit the height of the popover? Do I need to set the tableview height (based on headers, footers, row heights) or i开发者_Python百科s there a better way? I'm hoping not to have to hard code the height. (A hardcoded max height would be fine, though.)


viewDidAppear

self.contentSizeForViewInPopover = CGSizeMake(320, 400);
self.navigationController.contentSizeForViewInPopover = CGSizeMake(320, 400);

this way you set the size of the Popover.
The hight could be calculated with – tableView:heightForHeaderInSection: and – tableView:heightForRowAtIndexPath:

0

精彩评论

暂无评论...
验证码 换一张
取 消