Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
public static class AutolayoutHelper
{
	[DllImport (Constants.ObjectiveCLibrary, EntryPoint = "objc_msgSend")]
	static extern IntPtr IntPtr_objc_msgSend (IntPtr receiver, IntPtr selector);

	public static void AutoLayoutTrace ()
	{
		var trace = Runtime.GetNSObject (IntPtr_objc_msgSend (UIApplication.SharedApplication.KeyWindow.Handle, new Selector ("_autolayoutTrace").Handle));

		Console.WriteLine ("AutoLayout Trace");
		Console.WriteLine ("****************");
		Console.WriteLine (trace);
	}

	public static void RecursiveDescription ()
	{
		var desc = Runtime.GetNSObject (IntPtr_objc_msgSend (UIApplication.SharedApplication.KeyWindow.Handle, new Selector ("recursiveDescription").Handle));

		Console.WriteLine ("Recursive Description");
		Console.WriteLine ("**********************");
		Console.WriteLine (desc);
	}
		
	public static void AmbiguousLayoutTrace (this UIView view)
	{
		foreach (UIView v in view.Subviews) {
			if (v.HasAmbiguousLayout) {
				Console.WriteLine ("Ambiguous {0}", v);
			}
		}
	}

	public static void ShowAmbiguity (this UIView view)
	{
		foreach (UIView v in view.Subviews) {
			if (v.HasAmbiguousLayout) {
				v.ExerciseAmbiguityInLayout ();
			}
		}
	}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment