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

Syntax

[Foundation.Export("constraintsAffectingLayoutForAxis:")]
[ObjCRuntime.Availability(Introduced=ObjCRuntime.Platform.iOS_6_0)]
public virtual NSLayoutConstraint[] GetConstraintsAffectingLayout (UILayoutConstraintAxis axis)

Parameters

axis
The direction of interest.

Returns

The default value is an empty array.

Remarks

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

The returned array may contain UIKit.NSLayoutConstraints that do not explicitly reference this UIKit.UIView but which nonetheless affect the UIView.Frame. For instance, if this is pinned to anotherView and anotherView is pinned to it's UIView.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) UIKit.NSLayoutConstraints.

If this method is called directly from within UIViewController.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.

C# Example

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))
    {
      Console.WriteLine(c2);
    }
  });
});
              

Requirements

Namespace: UIKit
Assembly: Xamarin.iOS (in Xamarin.iOS.dll)
Assembly Versions: 0.0.0.0