[英]Changing Presented view controller constraints
I have tried to find an answer to this for a while. 我试了一段时间寻找答案。 What I want to do is to change the constraints of a ViewController in relation with his "father".
我想要做的是更改与他的“父亲”有关的ViewController的约束。 Here is what I tried to do, but I get an error:
这是我尝试执行的操作,但出现错误:
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();
}
When I am adding the constraints, I get this error: 添加约束时,出现以下错误:
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.
Please help me find out, thanks 请帮我找出来,谢谢
You need to add the missing view parameter. 您需要添加缺少的view参数。
Create(NSObject, NSLayoutAttribute, NSLayoutRelation, NSObject, NSLayoutAttribute, nfloat, nfloat)
创建(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.