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

Selecting images and videos


In this recipe, we will learn how to provide the user with the ability to import images and videos from the device album.

Getting ready

Create a new Single View Application in Xamarin Studio and name it ImagePickerApp. For this recipe, we will need some images to be stored in the simulator's photo albums.

An easy way to add images to the simulator is by navigating to a web page with Safari. Long-tapping (click + hold) on any image in Safari will show us an action sheet with a Save option. Tapping the option saves the image to the photo albums.

How to do it...

Perform the following steps:

  1. Open the ImagePickerAppViewController.xib file in Interface Builder and add UIImageView and UIButton to it.

  2. Enter the following code in the ViewDidLoad method:

    this.imagePicker = new UIImagePickerController();
    this.imagePicker.FinishedPickingMedia += this.ImagePicker_FinishedPickingMedia;
    this.imagePicker.Canceled += this.ImagePicker_Cancelled;
    this.imagePicker.SourceType = UIImagePickerControllerSourceType...