问题
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