UICollectionViewCell content not resizing to layout.itemSize

放肆的年华 提交于 2020-01-05 04:44:09

问题


I have a UICollectionViewCell subclass that I have defined in a nib...

It uses AutoLayout to layout all of the (two, lol) components. The date picker is laid out with left, right and bottom constraints to the superview and a height constraint to make sure it always shows full content.

Then, when configuring the layout of the collection view I use this...

_layout = [[UICollectionViewFlowLayout alloc] init];
_layout.itemSize = CGSizeMake(CGRectGetWidth(self.collectionView.frame), CGRectGetHeight(self.collectionView.frame));
_layout.minimumInteritemSpacing = 0;
_layout.minimumLineSpacing = 0;

This works as when I'm debugging the view I can see that the frame of the UICollectionViewCell is correct, but the content of the cell is not resizing as you can see from these two screenshots.

Collection View Cell selected and is correct.

Content of collection view selected and is not correct.

In fact, you can see that the content is the same size and shape as defined in the nib. But this should resize to match the cell size. If I make the nib content really small it stays really small in the app.

This is, potentially, happening in UITableViewCells too as the cell separators are not showing all the way across the screen for bigger devices.

来源:https://stackoverflow.com/questions/26019122/uicollectionviewcell-content-not-resizing-to-layout-itemsize

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!