Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/ios/93.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Ios 获取UITableView的最小高度_Ios_Cocoa Touch_Uitableview - Fatal编程技术网

Ios 获取UITableView的最小高度

Ios 获取UITableView的最小高度,ios,cocoa-touch,uitableview,Ios,Cocoa Touch,Uitableview,我正在将UITableViewController的tableview添加为自定义视图的子视图 因此,我需要找出(分组的、禁用滚动的)表视图的高度,换句话说,就是增加的高度:所有单元格+部分标题+标题+填充。 height属性始终返回430pts:(由于UITableView是UIScrollView的子类,因此可以通过以下方式获取其“内容大小”: tableView.contentSize 然后您可以通过以下方式获得高度: tableView.contentSize.height 下面是我

我正在将UITableViewController的tableview添加为自定义视图的子视图

因此,我需要找出(分组的、禁用滚动的)表视图的高度,换句话说,就是增加的高度:所有单元格+部分标题+标题+填充。


height属性始终返回430pts:(

由于
UITableView
UIScrollView
的子类,因此可以通过以下方式获取其“内容大小”:

tableView.contentSize
然后您可以通过以下方式获得高度:

tableView.contentSize.height

下面是我使用TableViewController实现此功能的代码

只需实现
-(CGSize)contentsizeforviewinpover
,如下所示:

- (CGSize)contentSizeForViewInPopover {
    NSInteger height = 0;

    for (NSInteger i = 0; i < [self.tableView numberOfSections]; i++) {
        height = height + [self.tableView rectForSection:i].size.height;
    }

    return CGSizeMake(320, height);
}
-(CGSize)contentsizeforviewinpover{
NSInteger高度=0;
对于(NSInteger i=0;i<[self.tableView numberOfSections];i++){
高度=高度+[self.tableView rectForSection:i].size.height;
}
返回CGSizeMake(320,高度);
}

我刚刚返回了320的宽度,因为这在我试图在其中显示TableView的UIPopoverController中工作得很好。

谢谢,我也这么认为,但奇怪的是我的“TableView.contentSize.height”是(null)!我找到了一个解决方案,但它非常难看:几个绘图矩形可以作为TableView的属性使用。(例如,
rectForSection