最终结果是在旋转设备后调整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
答案 0 :(得分:1)
覆盖其中一个旋转UIviewController委托方法,尝试willRotateToInterfaceOrientation(可能做了而不是更好)然后当你抓住它时,重新加载你的表视图并设置一些标志以知道它被旋转。
然后实现UICollectionViewDelegateFlowLayout,collectionView:layout:sizeForItemAtIndexPath: (根据方向在这里改变大小)