UIView.GetConstraintsAffectingLayout(UILayoutConstraintAxis) Method


Returns the array of NSLayoutConstraint that are affecting the layout of the UIView along the specified axis.

[ObjCRuntime.Introduced(ObjCRuntime.PlatformName.iOS, 6, 0, ObjCRuntime.PlatformArchitecture.All, null)]
public virtual UIKit.NSLayoutConstraint[] GetConstraintsAffectingLayout (UIKit.UILayoutConstraintAxis axis);
abstract member GetConstraintsAffectingLayout : UIKit.UILayoutConstraintAxis -> UIKit.NSLayoutConstraint[]
override this.GetConstraintsAffectingLayout : UIKit.UILayoutConstraintAxis -> UIKit.NSLayoutConstraint[]



The direction of interest.



The default value is an empty array.



This is a debugging method that should not be used in production applications.

The returned array may contain NSLayoutConstraints that do not explicitly reference this UIView but which nonetheless affect the Frame. For instance, if this is pinned to anotherView and anotherView is pinned to it's Superview, the method may return both constraints.

This method is a debugging oriented helper method and is not guaranteed to return the complete set (or any) NSLayoutConstraints.

If this method is called directly from within ViewDidLoad(), it will generally return an empty array. If it is invoked as shown in the following example, it appears to be more likely to provide a comprehensive answer.

mainView.AddConstraints(NSLayoutConstraint.FromVisualFormat("H:|-[blue]-|", 0, new NSDictionary(), viewsDictionary));
mainView.AddConstraints(NSLayoutConstraint.FromVisualFormat("V:|-[blue]-(==30)-[green(==blue)]-|", 0, new NSDictionary(), viewsDictionary));
mainView.AddConstraints(NSLayoutConstraint.FromVisualFormat("|-[green(==blue)]-|", 0, new NSDictionary(), viewsDictionary));

System.Threading.ThreadPool.QueueUserWorkItem(delegate {
  InvokeOnMainThread(delegate {
    foreach(var c2 in blueView.GetConstraintsAffectingLayout(UILayoutConstraintAxis.Horizontal))

Applies to