我最终得到以下结果:
在子视图控制器中,我创建了一个单独的方法来获取表视图的值。之后我设置了首选的内容大小。
public void setDocumentList(List<string> documentList){
this.documentList = documentList;
this.TableView.ReloadData ();
// adjust size for popover
float height = TableView.ContentSize.Height;
if (this.View.Bounds.Height > 0) {
// limit the max size of the popover
height = Math.Min (this.View.Bounds.Height, height);
}
this.PreferredContentSize = new SizeF (320f, height);
}
在我的容器中,我有一个类似的功能,但在这里我只设置了首选的内容大小。
public void setDocumentList(List<string> documentList){
documentListController.setDocumentList (documentList);
this.PreferredContentSize = documentListController.PreferredContentSize;
// some autolayout constraints ...
}
这种作品。我得到了正确的值,但弹出框的值一开始就不正确。如果有人想知道这是 C# 语言。我仍然愿意寻求更好的解决方案。