UIViewController.ViewIfLoaded Property
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.
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();
}