我需要用他的 contentSize 的高度来调整我的 UITableView 的大小,我做了这个:
private void ajustHeightOfTableView()
{
nfloat height = tableViewCores.ContentSize.Height;
nfloat maxHeight = tableViewCores.Superview.Frame.Size.Height - tableViewCores.Frame.Y;
if (height > maxHeight)
height = maxHeight;
UIView.Animate(0.25, new Action (() => {
this.tableViewAjustHeight.Constant = height;
this.contentView.SetNeedsUpdateConstraints();
}));
}
和
public override void ViewDidAppear (bool animated)
{
base.ViewDidAppear (animated);
ajustHeightOfTableView();
}
我有一个 IBOutlet,它带有我的 UITableView 的高度约束...所以我调整了在 reloadData() 之后调用我的函数 ajustHeightOfTableView 的 tableview 的大小...
问题是:在我的 UITableView 下方,我有另一个带有按钮和文本字段的 UIView 当我调整 tableView 的大小时,我的另一个 View 不起作用!她没有响应用户交互...我的问题是在调整大小后 View 不在正确的位置。
我对 UITableView 和 UIView 之间的垂直间距有另一个约束,如下所示: IMAGE 1
此约束是将我的 View 放在正确的空间中,另一个是我的 uitableview 调整大小...
这里是我的 UITableView 约束高度: IMAGE2
有人知道我在这里做错了什么吗?
最佳答案
我不知道你是否可以分别调整高度和宽度,但我知道一种方法可以在两个方向上将网页缩放到你的 View 中。这是使用 ScalesPageToFit
完成的。
UIWebView webView = new UIWebView (new RectangleF (0, 0, cellWidth, cellHeight));
webView.ScalesPageToFit = true;
webView.ScrollView.MinimumZoomScale = 1f;
webView.ScrollView.MaximumZoomScale = 5f;
webView.LoadRequest (new NSUrlRequest(new NSUrl(URL)));
调整 UIWebView 的 Frame
将不起作用。
希望这些简短的信息对您有所帮助。祝你好运!
爱与问候, 比约恩
关于ios - UITableView Auto Height With Constraint 问题 Xamarin.iOS,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29305959/