user1366911
user1366911

Reputation: 917

Size Classes and UITableViewCell/UICollectionViewCell sizes

Size classes are phenomenal for specific constraints between devices. However you can't add constraints directly to a UITableViewCell or a UICollectionViewCell - specifically height and width.

I want to have a larger UICollectionViewCell on iPad Size Classes than iPhone so I always have three cells per row in portrait mode regardless of device. However, because I can't add constraints to the Cell, and adjusting the height/width directly is independent of size classes, I'm at a bit of a loss.

Upvotes: 1

Views: 853

Answers (1)

Vinzzz
Vinzzz

Reputation: 11724

UIViewControllers conform to UIContentContainer protocol, so you you will be told whenever controller view's size is changing by overriding -viewWillTransitionToSize:withTransitionCoordinator: (this new iOS 8 API is also called on rotations) changing your UICollectionViewFlowLayout itemSize (which is responsible for cells size).

Upvotes: 1

Related Questions