UICollectionView的动态单元格宽度取决于标签宽度
我有一个UICollectionView,它从包含标签的可重用单元格加载单元格。数组为该标签提供内容。我可以使用sizeToFit轻松根据内容宽度调整标签宽度。但是我无法制作适合标签的单元格。 这是代码 - (void)viewDidLoad { [super viewDidLoad]; // Do any additional setup after loading the view, typically from a nib. arrayOfStats = @[@"time:",@"2",@"items:",@"10",@"difficulty:",@"hard",@"category:",@"main"]; } - (NSInteger)collectionView:(UICollectionView *)collectionView numberOfItemsInSection: (NSInteger)section{ return [arrayOfStats count]; } - (CGSize)collectionView:(UICollectionView *)collectionView layout:(UICollectionViewLayout*)collectionViewLayout sizeForItemAtIndexPath:(NSIndexPath *)indexPath{ return CGSizeMake(??????????); } - (NSInteger)numberOfSectionsInCollectionView:(UICollectionView *)collectionView{ return 1; } - (UICollectionViewCell …