UICollectionView方向改变不幸?

时间:2015-08-19 09:01:59

标签: ios xcode swift uiscrollview uicollectionview

当我的集合视图位于底部并且我从纵向更改为横向时,单元格会从视图中消失,直到我必须将它们向下拖动,如下所示:

常规肖像视图:

enter image description here

旋转到景观时的视角:

enter image description here

从顶视图中拖出细胞:

enter image description here

我该如何解决这个问题?

1 个答案:

答案 0 :(得分:2)

-(void)willAnimateRotationToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation
                                             duration:(NSTimeInterval)duration
 {
    if (UIInterfaceOrientationIsLandscape(toInterfaceOrientation))
    {
       self.collectionViewObj.frame = CGRectMake(0, 0, 568, 320);
    } 
    else
    {
       self.collectionViewObj.frame = CGRectMake(0, 0, 320, 568);
    }
}