我正在使用uicollection视图来显示网格视图格式的图像。我能够显示单元格,但高度为&宽度不增加的iPad它只显示为小块。请告诉我如何使它动态。如何在iOS中为uicollection view cell制作动态大小?
[![在这里输入的形象描述] [1] [1]
我已经使用了如下使动态代码。
编译标志Collection视图布局事情
- (CGFloat)collectionView:(UICollectionView *)collectionView layout:(UICollectionViewLayout*)collectionViewLayout minimumInteritemSpacingForSectionAtIndex:(NSInteger)section {
if (collectionView==self.album_collection_view) {
return 2.0;
}
else
return 2.0;
}
- (CGFloat)collectionView:(UICollectionView *)collectionView layout:(UICollectionViewLayout*)collectionViewLayout minimumLineSpacingForSectionAtIndex:(NSInteger)section {
if (collectionView==self.album_collection_view) {
return 2.0;
}
else
return 2.0;
}
// Layout: Set Edges
- (UIEdgeInsets)collectionView:
(UICollectionView *)collectionView layout:(UICollectionViewLayout*)collectionViewLayout insetForSectionAtIndex:(NSInteger)section {
// return UIEdgeInsetsMake(0,8,0,8); // top, left, bottom, right
if (collectionView==self.album_collection_view) {
return UIEdgeInsetsMake(5,0,0,0);
}// top, left, bottom, right
else
return UIEdgeInsetsMake(5,0,0,0);
}
请告诉我,我怎样才能解决这个问题呢?
它会为所有设备制作dynmaic尺寸。 – Techiee
如果你想在所有设备的每一行显示4单元格,然后通过'返回CGSizeMake(collectionView.frame.size.width/4,collectionView.frame.size.width/4);'所以在所有设备按照你的collectionview宽度将减少并增加您的单元格高度和宽度。如果你想在特定的设备上显示一些特定的高度和宽度,那么你必须检查设备,如果它的5s,6或ipad,并根据您的需要指定高度。 –