UIViewController.LoadViewIfNeeded Метод

Определение

При необходимости синхронно загружает из View раскадровки или 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
Атрибуты

Комментарии

Этот метод можно использовать, чтобы убедиться, что View объект был создан, если UIViewController имеет связанную раскадровку или NIB. (См. также сведения об ViewIfLoaded.)

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

Применяется к

См. также раздел