Book Image

iOS Development with Xamarin Cookbook

By : Dimitrios Tavlikos (USD)
Book Image

iOS Development with Xamarin Cookbook

By: Dimitrios Tavlikos (USD)

Overview of this book

Table of Contents (22 chapters)
iOS Development with Xamarin Cookbook
Credits
About the Author
About the Reviewers
www.PacktPub.com
Preface
Index

Modal view controllers


In this recipe, we will discuss how to display view controllers modally.

Getting ready

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.

How to do it…

Perform the following steps:

  1. Add two view controllers to the project and name them MainController and ModalController.

  2. Open the MainController.xib file in Interface Builder and add a button on its view with the title Present. Create and connect the appropriate outlet for the button.

  3. In the MainController class, add the following code in the ViewDidLoad method:

    this.buttonPresent.TouchUpInside += async (s, e) => {
      ModalController modalController = new ModalController();
      await this.PresentViewControllerAsync(modalController...