Skip to content

Instantly share code, notes, and snippets.

@mikebluestein
Created July 20, 2015 19:34
Show Gist options
  • Save mikebluestein/1b4016f81a3e75565483 to your computer and use it in GitHub Desktop.
Save mikebluestein/1b4016f81a3e75565483 to your computer and use it in GitHub Desktop.
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