0

最终结果是,一旦设备旋转,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

4

1 回答 1

1

覆盖旋转 UIviewController 委托方法之一,尝试 willRotateToInterfaceOrientation (可能会而不是 will 更好)然后当你抓住它时,重新加载你的表格视图并设置一些标志以知道它是旋转的。

然后实现UICollectionViewDelegateFlowLayout,collectionView:layout:sizeForItemAtIndexPath:(这里根据方向改变大小)

于 2013-09-25T02:55:56.520 回答