2013-09-24 24 views
0

最终的结果是一旦设备旋转后,cell.title和cell.description就会调整大小,以便填充整个屏幕。这个collectionviewcontroller在Viewcontroller中,所以我需要一个特定于单元的解决方案。如何在旋转时调整CollectionView的特定单元格大小?

- (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

回答

1

覆盖的旋转的UIViewController委托方法之一,尝试willRotateToInterfaceOrientation(大概做了反而会更好)然后,当你抓住它,重新加载你的表格视图并设置一些标志以知道它被旋转。 (根据方位变化大小这里)

然后实现UICollectionViewDelegateFlowLayout,的CollectionView:布局:sizeForItemAtIndexPath

相关问题