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

Displaying data in a grid


In this recipe, we will discuss using the UICollectionView object to display data in a grid-like layout. The UICollectionView class was introduced in iOS 6, and is a very useful control that was missed by iOS developers. Prior to UICollectionView, the only way to display data in a grid was to create a custom control, which was not a very easy task.

Getting ready

Create a new project in Xamarin Studio and name it CollectionViewApp. We will also need something to display, so add an image to the project.

How to do it...

Perform the following steps:

  1. Open the CollectionViewAppViewController.xib file in Interface Builder and add a UICollectionView on its main view. The following screenshot shows the object in the object browser:

  2. Back in Xamarin Studio, add the following class:

    public class ImageCell : UICollectionViewCell {
      public const string CELLID = "ImageCell";
      public ImageCell(IntPtr handle) : base(handle) {
        this.Initialize();
      }
      public UIImageView ImageView...