在UIPopoverViewController中显示UITableView时,如何自动调整高度?

问题描述:

我正在展示一个UIPopoverViewController,其中UINavigationController其中有UITableViewController。 tableview只有四行,但popover的高度与屏幕允许的一样大。在UIPopoverViewController中显示UITableView时,如何自动调整高度?

限制弹出高度的正确方法是什么?我是否需要设置tableview高度(基于页眉,页脚,行高)还是有更好的方法?我希望不必硬编码高度。 (硬编码的最大高度就可以了,虽然)。

viewDidAppear

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

这样你设置的酥料饼的大小。
高度可以用– tableView:heightForHeaderInSection:– tableView:heightForRowAtIndexPath: