Using Azure Marketplace’s Bing Image Search on iOS with UICollectionView in C#

The Windows Azure Marketplace now includes the Bing web service. Using the image search feature, combined with a UICollectionView, can be used to display images in a grid on iOS like this:

Consuming the Bing service with Xamarin on iOS can be accomplished just like anywhere else C# is available.  The UI here consists of a UICollectionView, using a UICollectionViewFlowLayout to achieve the grid display. Programming against a UICollectionView is very similar to using a UITableView, the big difference being that UICollectionView works with a layout class to achieve any layout you desire. iOS provides a very flexible UICollectionViewFlowLayout class that can be used  when a line-based layout is needed. Also, you can subclass UICollectionViewLayout directly as well to implement layouts that aren’t line-based.

You can get the code for this example here: https://github.com/mikebluestein/BingImageGrid

To run the exmaple, you need to sign up for an API key from the Windows Azure Marketplace.

For more information on using Collection Views, see this article in Xamarin’s Developer Center:

http://docs.xamarin.com/ios/tutorials/Introduction_to_CollectionViews

Leave a comment