[英]Changing Presented view controller constraints
我试了一段时间寻找答案。 我想要做的是更改与他的“父亲”有关的ViewController的约束。 这是我尝试执行的操作,但出现错误:
partial void BackAction(Foundation.NSObject sender)
{
/// My "parent" view controller - the one that presented this view
UIViewController ApplicationViewController = Application.GetPresentedViewController("ApplicationViewController");
/// Here I am trying to update the constrains in relation with his father
View.AddConstraint(NSLayoutConstraint.Create(ApplicationViewController.View, NSLayoutAttribute.LeftMargin, NSLayoutRelation.Equal, 1, 30));
/// and also let the view digest the constrains
View.UpdateConstraints();
}
添加约束时,出现以下错误:
Objective-C exception thrown.
Name: NSInvalidArgumentException
Reason: NSLayoutConstraint for <UILayoutContainerView: 0x104903e70; frame = (0 0; 375 812); autoresize = W+H; layer = <CALayer: 0x1c802ff20>>:
A multiplier of 0 or a nil second item together with a location for the first attribute creates an illegal constraint of a location equal to a constant.
Location attributes must be specified in pairs.
请帮我找出来,谢谢
您需要添加缺少的view参数。
创建(NSObject,NSLayoutAttribute,NSLayoutRelation,NSObject,NSLayoutAttribute,nfloat,nfloat)
View.AddConstraint(NSLayoutConstraint.Create(ApplicationViewController.View, NSLayoutAttribute.LeftMargin, NSLayoutRelation.Equal,View,NSLayoutAttribute.LeftMargin,1, 30));
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.