Bearbeiten

Freigeben über


UIViewController.ViewIfLoaded Property

Definition

Returns the View if it has been instantiated; otherwise, returns null.

[ObjCRuntime.Introduced(ObjCRuntime.PlatformName.iOS, 9, 0, ObjCRuntime.PlatformArchitecture.All, null)]
public virtual UIKit.UIView ViewIfLoaded { [ObjCRuntime.Introduced(ObjCRuntime.PlatformName.iOS, 9, 0, ObjCRuntime.PlatformArchitecture.All, null)] [Foundation.Export("viewIfLoaded", ObjCRuntime.ArgumentSemantic.Strong)] get; }
member this.ViewIfLoaded : UIKit.UIView

Property Value

A null return indicates that the View has not yet been loaded.

This value can be null.

Attributes

Remarks

Because UIView are relatively heavyweight compared to TUIViewController objects, the View object is lazily initialized. Developers can test if the View has been initialized by calling this method, which returns null if the View had not yet been loaded. Developers can call LoadViewIfNeeded() to force the loading of the View.

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

Applies to