UIViewController.LoadViewIfNeeded Method
Definition
Important
Some information relates to prerelease product that may be substantially modified before it’s released. Microsoft makes no warranties, express or implied, with respect to the information provided here.
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();
}