In this recipe, we will discuss how to display view controllers modally.
A modal view controller is any controller that is presented above other views or controllers. The concept is similar to displaying a Windows Form as a dialog, which takes control of the interface and does not allow access to other windows of the application unless it is dismissed. Create a new iPhone Empty Project in Xamarin Studio and name it ModalControllerApp
.
Perform the following steps:
Add two view controllers to the project and name them
MainController
andModalController
.Open the
MainController.xib
file in Interface Builder and add a button on its view with the titlePresent
. Create and connect the appropriate outlet for the button.In the
MainController
class, add the following code in theViewDidLoad
method:this.buttonPresent.TouchUpInside += async (s, e) => { ModalController modalController = new ModalController(); await this.PresentViewControllerAsync(modalController...