UIViewController.LoadViewIfNeeded 方法

定义

如有必要,请从情节提要或 NIB 同步加载 View

[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
属性

注解

如果 UIViewController 对象具有关联的 Storyboard 或 NIB,则此方法可用于确保View对象已实例化。 (另请参阅 ViewIfLoaded。)

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

适用于

另请参阅