Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

iOS 8 GM does not update constraints on collection views

In Xcode 6 Beta 7 and all versions before it, I had a collection view that would update its constraints on its cells when an iPad would rotate between landscape and portrait. Now, it doesn't update at all, and in fact it looks exactly like how I leave it in the XIB, which implies to me that it's not updating at all. It appears that the reusable views I'm using are updating correctly, but the cells certainly are not.

Has anyone else run into this issue yet? Anyone have any ideas for how to get past it?

I'm using the iOS 7.1 simulator.

like image 349
Sean Freitag Avatar asked Sep 09 '14 20:09

Sean Freitag


2 Answers

You need to make a subclass of UICollectionViewCell and make that subclass as the superclass of ALL of your cells.

Example:

@interface MDTCollectionViewCell : UICollectionViewCell
@end

@implementation MDTCollectionViewCell

- (void)setBounds:(CGRect)bounds {
    [super setBounds:bounds];
    self.contentView.frame = bounds;
}

@end
like image 51
Sean Freitag Avatar answered Oct 26 '22 08:10

Sean Freitag


Override the custom cell's layoutSubviews as a temporary fix:

override func layoutSubviews() {
    contentView.frame = bounds
    super.layoutSubviews()
}
like image 21
Attila H Avatar answered Oct 26 '22 08:10

Attila H