最终结果是,一旦设备旋转,cell.title 和 cell.description 就会重新调整大小,以填满整个屏幕。这个 collectionviewcontroller 在 Viewcontroller 中,所以我需要一个特定于单元格的解决方案。
- (UICollectionViewCell *) collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath
{
if(collectionView == collection1)
{
SliderCollectionViewCell *cell = [collectionView dequeueReusableCellWithReuseIdentifier:@"articleCellslider1"
forIndexPath:indexPath];
NSDictionary *item = [_articleListslider objectAtIndex:indexPath.item];
// set the article image
[cell.image setImageWithURL:[item objectForKey:@"image"]];
// set the text of title UILabel
cell.title.text = [NSString stringWithFormat:@"%@\n\n\n\n", [item objectForKey:@"title"]];
cell.title.textColor = [UIColor colorWithRed:33.0f/255.0f green:74.0f/255.0f blue:146.0f/255.0f alpha:1.0f];
cell.title.backgroundColor = [UIColor colorWithRed:255.0f/255.0f green:255.0f/255.0f blue:255.0f/255.0f alpha:0.5f];
// set the text of summary UILabel
cell.description.text = [NSString stringWithFormat:@"%@\n\n\n\n\n\n\n\n\n", [item objectForKey:@"description"]];
cell.description.font = [UIFont fontWithName:@"Helvetica Neue" size:14];
cell.description.backgroundColor = [UIColor colorWithRed:255.0f/255.0f green:255.0f/255.0f blue:255.0f/255.0f alpha:0.5f];
cell.targetURL = [item objectForKey:@"link"];
cell.sliderphoto = [item objectForKey:@"sliderphoto"];
cell.date.text = [NSString stringWithFormat:@"%@\n\n\n\n", [item objectForKey:@"pubDate"]];
cell.category.text = [NSString stringWithFormat:@"%@\n\n\n\n", [item objectForKey:@"category"]];
return cell;
[self performSegueWithIdentifier:@"Slider" sender:indexPath];
}
我想在旋转时特别调整大小的单元格是 cell.title 和 cell.description