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

Managing album items directly


In this recipe, we will discuss how to programmatically access the device's photo album.

Getting ready

Create a new Single View Application in Xamarin Studio and name it ManageAlbumApp.

Note

This example works on the simulator. At least one image must exist in the simulator's photo album.

How to do it...

Perform the following steps:

  1. Add a button on the main view of the controller.

  2. Enter the following using directive in the MainController.cs file:

    using MonoTouch.AssetsLibrary;
  3. Add the following code in the ViewDidLoad method:

    this.btnEnumerate.TouchUpInside += (s, e) => {
      if (ALAssetsLibrary.AuthorizationStatus == ALAuthorizationStatus.Authorized ||
        ALAssetsLibrary.AuthorizationStatus == ALAuthorizationStatus.NotDetermined) {
        this.assetsLibrary = new ALAssetsLibrary();
        this.assetsLibrary.Enumerate(ALAssetsGroupType.All, this.GroupsEnumeration, this.GroupsEnumerationFailure);
      }
    } ;
  4. Add the following methods in the class:

    private void GroupsEnumeration...