Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/ios/105.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
C# 更改显示的视图控制器约束_C#_Ios_Uiviewcontroller_Constraints - Fatal编程技术网

C# 更改显示的视图控制器约束

C# 更改显示的视图控制器约束,c#,ios,uiviewcontroller,constraints,C#,Ios,Uiviewcontroller,Constraints,我试图找到一个答案已经有一段时间了。我想做的是更改ViewController与其“父对象”之间的约束。 以下是我尝试执行的操作,但出现了一个错误: partial void BackAction(Foundation.NSObject sender) { /// My "parent" view controller - the one that presented this view UIViewController ApplicationViewController = A

我试图找到一个答案已经有一段时间了。我想做的是更改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.
引发了Objective-C异常。 名称:NSInvalidArgumentException 原因:NSLayoutConstraint用于: 乘数为0或零秒的项与第一个属性的位置一起创建等于常量的位置的非法约束。 位置属性必须成对指定。
请帮我查找,谢谢

您需要添加缺少的视图参数

创建(NSObject、NSLayoutAttribute、NSLayoutRelation、NSObject、, nslayouttribute,nfloat,nfloat)


仍然不工作,抛出Objective-C异常。名称:NSInternalInconsistencyException原因:无法在视图层次结构未准备好约束的情况下设置布局。可能,我需要以某种方式初始化(或显示)上一个viewcontroller。但是,我仍然不知道如何在不关闭当前viewcontroller的情况下显示上一个viewcontroller。是否确定您的视图位于ApplicationViewController.View中?视图需要先添加到父视图中,即约束。是否需要显示上一个视图而不关闭当前VC?是的,我需要,我想使用平移手势向左滑动上一个视图
View.AddConstraint(NSLayoutConstraint.Create(ApplicationViewController.View, NSLayoutAttribute.LeftMargin, NSLayoutRelation.Equal,View,NSLayoutAttribute.LeftMargin,1, 30));