iOS:UICollectionViewCell根据屏幕大小自动resize

我试图在集合视图中创建10个单元格(与屏幕大小相同)。 当我在iphone5s模拟器中运行我的应用程序时,视图恰好包含5个单元格。 但是当我切换到iphone6p模拟器时,视图包含超过5个单元格。 我应该如何调整单元格大小,以便屏幕中的单元格数量在不同的屏幕尺寸上保持一致?

-(CGSize)collectionView:(UICollectionView *)collectionView layout:(UICollectionViewLayout *)collectionViewLayout sizeForItemAtIndexPath:(NSIndexPath *)indexPath { int numberOfCellInRow = 3; CGFloat cellWidth = [[UIScreen mainScreen] bounds].size.width/numberOfCellInRow; return CGSizeMake(cellWidth, cellWidth); }