UIViewController: presentedViewController property
The presentedViewController property is the modal view controller this view controller presented.
Value
A UIViewController, or null.
- Read-only; assigning to it throws
TypeError. - The default is
null: nothing is presented. - Becomes the presented view controller immediately after calling
presentViewController(); goes back tonullafterdismissViewController()dismisses it and the animation ends. - There is no dedicated change event. Changes caused by code are known to that code; when the user drags a modal view controller away, learn about it from
dismisson the presented view controller.
Examples
js
const page = new UIViewController();
const alert = UIAlertController.alertControllerWithTitle('Syncing…', {
preferredStyle: 'alert',
});
async function show() {
await page.presentViewController(alert, { animated: true });
console.log(page.presentedViewController === alert);
}Effect: Calling show() while page is on screen presents the alert, and the console prints true.
Corresponding iOS API
UIViewController.presentedViewController.