Keeping the contentOffset in a UICollectionView while rotating Interface Orientation

后端 未结 24 1354
野性不改
野性不改 2020-12-04 07:22

I\'m trying to handle interface orientation changes in a UICollectionViewController. What I\'m trying to achieve is, that I want to have the same contentOffset afte

24条回答
  •  北海茫月
    2020-12-04 08:01

    -(CGSize)collectionView:(UICollectionView *)collectionView layout:(UICollectionViewLayout *)collectionViewLayout sizeForItemAtIndexPath:(NSIndexPath *)indexPath {
        CGSize pnt = CGSizeMake(70, 70);
        return pnt; }
    
    -(UIEdgeInsets)collectionView:(UICollectionView *)collectionView layout:(UICollectionViewLayout*)collectionViewLayout insetForSectionAtIndex:(NSInteger)section {
    
    //    UIEdgeInsetsMake(<#CGFloat top#>, <#CGFloat left#>, <#CGFloat bottom#>, <#CGFloat right#>)
        return UIEdgeInsetsMake(3, 0, 3, 0); }
    

    This way you can adjust the content offset and the size of your cell.

提交回复
热议问题