Helo all,
我已经创建了一个UIcollectionView单元格。我想要设置高度&例如,如果高度为80,则为所有装置的宽度。在iphone 5s上宽度为90,那么它也应该在其他设备上使用。我正在使用这种方法。
-(CGSize)collectionView:(UICollectionView *)collectionView layout:(UICollectionViewLayout*)collectionViewLayout sizeForItemAtIndexPath:(NSIndexPath *)indexPath
{
return CGSizeMake(80, 90);
}
答案 0 :(得分:0)
尝试使用此
-(CGSize)collectionView:(UICollectionView *)collectionView layout:(UICollectionViewLayout *)collectionViewLayout sizeForItemAtIndexPath:(NSIndexPath *)indexPath{
return CGSizeMake(self.view.frame.size.width/.25, self.view.frame.size.width/.28);
}
答案 1 :(得分:0)
您所要做的就是将细胞的尺寸乘以您想要的任何比例。如果80x90是iPhone 5上您想要的尺寸,请参考指南like this one计算相应的乘数。例如,5的分辨率为320 x 568,6为375 x 667,因此宽度乘数为375/320,高度为667/568。 (我会让你做数学。:))
答案 2 :(得分:-1)
使用此
-(CGSize)collectionView:(UICollectionView *)collectionView layout:(UICollectionViewLayout *)collectionViewLayout sizeForItemAtIndexPath:(NSIndexPath *)indexPath{
return CGSizeMake(self.view.frame.size.width/2, self.view.frame.size.width/2);
-(CGFloat)collectionView:(UICollectionView *)collectionView layout:(UICollectionViewLayout *)collectionViewLayout minimumLineSpacingForSectionAtIndex:(NSInteger)section{
return 0
;}
-(CGFloat)collectionView:(UICollectionView *)collectionView layout:(UICollectionViewLayout *)collectionViewLayout minimumInteritemSpacingForSectionAtIndex:(NSInteger)section{
return 0; }