簡體   English   中英

更改呈現的視圖控制器約束

[英]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.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM