Data Source
Send Feedback

Glossary Item Box

Topic Overview

Purpose

This topic provides an informational overview of supplying data to the IGFlowLayoutView™ control.

In this topic

This topic contains the following sections:


Data Source

Introduction

To supply data to the IGFlowLayoutView you must adopt the IGFlowLayoutDataSource protocol or create a new class that adopts this protocol and set the dataSource property on the IGFlowLayoutView. The IGFlowLayoutDataSource has 4 required methods that are used to populate the IGFlowLayoutView.

  • -(CGSize)numberOfBlocksInViewport:(IGFlowLayoutView*)flowLayoutView;
  • -(NSInteger)numberOfItemsInFlowLayoutView:(IGFlowLayoutView*)flowLayoutView;
  • -(CGSize)flowLayoutView:(IGFlowLayoutView*)flowLayoutView sizeForItemAtIndex:(NSInteger)index;
  • -(IGFlowLayoutViewCell*)flowLayoutView:(IGFlowLayoutView*)flowLayoutView cellAtIndex:(NSInteger)index;

By design, the data source for the IGFlowLayoutView uses blocks to represent the size of a flow layout item. For example, if your IGFlowLayoutView has a size of 1024x768 and the numberOfBlocksInViewport: is set to return a CGSize of (4, 4), each block would have a size of 256x192. This means that your IGFlowLayoutView will fit 16 blocks in the viewport. If your data source returns a number higher than the multiplied CGSize from numberOfItemsInFlowLayoutView:, the viewport will then be scrollable. To learn more about the scrolling layout of the IGFlowLayoutView, visit the Layouts topic.

The returned CGSize from the flowLayoutView:sizeForItemAtIndex: method block size for each item is the bases on . Using the same amount of blocks in our viewport with a CGSize of (4, 4) as mentioned previously, an item that returns its CGSize of (2,3) would have an actual size of 512x576.

The IGFlowLayoutDataSource populates layout items by calling the flowLayoutView:cellAtIndex: method, which is the same technique you would use to populate items on the UITableView or IGGridView, by de-queuing a cell or creating a new one in this method. The difference is that a default IGFlowLayoutViewCell has content; it is just a container. To add content, set the contentView property of the cell to display any UIView.


Related Content

Topics

The following topic provides additional information related to this topic.

Topic

Purpose

This topic serves as a gateway to the features and functionality of the IGFlowLayoutView control.