In this recipe, we will learn how to provide the user with the ability to import images and videos from the device album.
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.
Perform the following steps:
Open the
ImagePickerAppViewController.xib
file in Interface Builder and addUIImageView
andUIButton
to it.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...