Controllers

To build a controller, first create and set up a layout object and then allocate the new instance and initialize it with the prepared layout:

UICollectionViewFlowLayout *layout =     [[UICollectionViewFlowLayout alloc] init]; layout.scrollDirection = UICollectionViewScrollDirectionHorizontal; MyCollectionController *mcc = [[MyCollectionController alloc]     initWithCollectionViewLayout:layout];

This snippet uses a collection view flow layout in its default form, only setting the scroll direction. As you’ll see through this chapter, you can do a lot more with layouts. Typically, you set additional properties or subclass system-supplied layouts and add your own behavior.

As a rule, you use the UICollectionViewFlowLayout ...

Get The Core iOS Developer’s Cookbook, Fifth Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.