我在其中我正在收集观察室的宽度作为应用:iOS中UIcollectionviewCell的动态宽度?
- (UIEdgeInsets)collectionView:
(UICollectionView *)collectionView layout:(UICollectionViewLayout*)collectionViewLayout insetForSectionAtIndex:(NSInteger)section {
return UIEdgeInsetsMake(20, 20,20,20);
}
- (CGSize)collectionView:(UICollectionView *)collectionView
layout:(UICollectionViewLayout *)collectionViewLayout
sizeForItemAtIndexPath:(NSIndexPath *)indexPath
{
CGRect screenRect = collection.frame;
CGFloat screenWidth = screenRect.size.width;
float cellWidth = screenWidth/count;
}
但现在我想对那些重要的单元格的宽度必须依赖于一个参数,如:
NSDictionary *dict=[arr objectAtIndex:indexPath.item];
float duration=([[dict valueForKey:@"duration"]floatValue]);
如果持续时间是45,那么它需要占用屏幕宽度的45%。任何人可以帮助我在这当我试图screenWidth * (duration/100.0)
它看起来像这样
float cellWidth = screenWidth/duration;试试这个 –