UIViewController.LoadViewIfNeeded UIViewController.LoadViewIfNeeded Method


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

[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


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

Applies to

See also