コード例 #1
0
		public static void AddSubview (this Control control, Control subView, bool useRoot = false)
		{
			var parentController = control.GetViewController (false);
			if (parentController != null) {
				parentController.AddChildViewController (subView.GetViewController ());
				return;
			}
			if (useRoot) {
				var window = control.GetContainerView () as UIWindow;
				if (window != null) {
					window.RootViewController = subView.GetViewController ();
					return;
				}
			}
			var parentView = control.GetContentView ();
			if (parentView != null) {
				parentView.AddSubview (subView.GetContainerView ());
				return;
			}

			throw new EtoException("Coult not add subview to parent");
		}