UIAutoresizingMasks works wrong in iPad ECSlidingViewController

67 views Asked by At

I have a container view ECSlidingViewController. Every item in the container is a NavigationViewController --> UIViewController

For example in one child view controller I have a UITableView with a UICollectionView in one static cell.

I try to implement a version for iPad that supports changing orientation of the screen, so I enabled all the authoresizing masks to fill the cell with the UICollectionView - and now I had a crazy issue - the frame of the cells - their width is very big. For example the table view frame is {{0, 0}, {1024, 768}} but the UICollectionView in static cell frame is {{0, 0}, {1792, 1301}}. How can I solve this issue?

1

There are 1 answers

4
l0gg3r On

So, I'm invalidating collectionView layout in willRotateToInterfaceOrientation:duration: so sizeForItemAtIndexPath: is called again.

- (CGSize)collectionView:(UICollectionView *)collectionView
                  layout:(UICollectionViewLayout *)collectionViewLayout
  sizeForItemAtIndexPath:(NSIndexPath *)indexPath
{
    return CGSizeMake(self.collectionView.frame.size.width, self.collectionView..frame.size.height);
}


- (void)willRotateToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation
                                duration:(NSTimeInterval)duration
{
    // Suppress the layout errors by invalidating the layout
    [self.collectionView.collectionViewLayout invalidateLayout];    
}