UIViewController.LoadViewIfNeeded Method

Definition

If necessary, synchronously loads the View from a Storyboard or NIB.

[Foundation.Export("loadViewIfNeeded")]
[ObjCRuntime.Introduced(ObjCRuntime.PlatformName.iOS, 9, 0, ObjCRuntime.PlatformArchitecture.All, null)]
public virtual void LoadViewIfNeeded ();
abstract member LoadViewIfNeeded : unit -> unit
override this.LoadViewIfNeeded : unit -> unit
Attributes

Remarks

This method can be used to ensure that the View object has been instantiated, if the UIViewController has an associated Storyboard or NIB. (See also ViewIfLoaded.)

var newVC = UIStoryboard.FromName("Main", NSBundle.MainBundle).InstantiateInitialViewController();
if (newVC.ViewIfLoaded == null)
{
    //This call blocks until the View is instantiated
    newVC.LoadViewIfNeeded();
}

Applies to

See also