table view in popover is not scrolling

本小妞迷上赌 提交于 2019-12-03 04:56:14

Use autoresizing correctly!

Popover - has content size

popoverView - its initial size should be the same as popover's content size and use UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight

tblViewMenu- its initial size should be the same as the size of its ancestor (popoverView), again, use UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight

Your table is not scrolling because it is so big that it doesn't needs scrolling. Only the popover is clipping it.

CGSize contentSize = CGSizeMake(320, 320);

UIView* popoverView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, contentSize.width, contentSize.height)];
popoverView.autoresizingMask = (UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight);

UITableView *tblViewMenu = [[UITableView alloc]initWithFrame:popoverView.bounds];
tblViewMenu.autoresizingMask = (UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight);

popoverContent.contentSizeForViewInPopover = contentSize;

Try set the ContentSize of the tableView, like this:

[tblViewMenu setContentSize:CGSizeMake(320,680)];

Also, I'd prefere to make the size of the tableView dynamic. depend on your tableView Datasource array.

UPDATE

To make the tableView dynamic, use this:

[tblViewMenu setContentSize:CGSizeMake(320, ([numbers count] * 32))];

And if you have a header view that has a hight like the other cells, just add 1 to [number count], that would be like this:

[tblViewMenu setContentSize:CGSizeMake(320, (([numbers count] + 1) * 32))];
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!