diff --git a/MasterPassword/ObjC/iOS/MPPasswordsViewController.m b/MasterPassword/ObjC/iOS/MPPasswordsViewController.m index 4a85e432..56653bbc 100644 --- a/MasterPassword/ObjC/iOS/MPPasswordsViewController.m +++ b/MasterPassword/ObjC/iOS/MPPasswordsViewController.m @@ -106,7 +106,7 @@ referenceSizeForHeaderInSection:(NSInteger)section { sizeForItemAtIndexPath:(NSIndexPath *)indexPath { UICollectionViewFlowLayout *layout = (UICollectionViewFlowLayout *)collectionViewLayout; - CGFloat itemWidth = UIEdgeInsetsInsetRect( self.passwordCollectionView.bounds, layout.sectionInset ).size.width; + CGFloat itemWidth = UIEdgeInsetsInsetRect( collectionView.bounds, layout.sectionInset ).size.width; return CGSizeMake( itemWidth, 100 ); } diff --git a/MasterPassword/ObjC/iOS/MPUsersViewController.m b/MasterPassword/ObjC/iOS/MPUsersViewController.m index ad93178f..48ad9016 100644 --- a/MasterPassword/ObjC/iOS/MPUsersViewController.m +++ b/MasterPassword/ObjC/iOS/MPUsersViewController.m @@ -108,9 +108,15 @@ typedef NS_ENUM( NSUInteger, MPActiveUserState ) { [self firedMarqueeTimer:nil]; } -- (void)viewDidLayoutSubviews { +- (void)viewWillLayoutSubviews { - [super viewDidLayoutSubviews]; + [self.avatarCollectionView.collectionViewLayout invalidateLayout]; + [super viewWillLayoutSubviews]; +} + +- (void)willAnimateRotationToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation duration:(NSTimeInterval)duration { + + [super willAnimateRotationToInterfaceOrientation:toInterfaceOrientation duration:duration]; [self.avatarCollectionView.collectionViewLayout invalidateLayout]; } @@ -262,15 +268,25 @@ typedef NS_ENUM( NSUInteger, MPActiveUserState ) { #pragma mark - UICollectionViewDelegateFlowLayout +- (CGSize) collectionView:(UICollectionView *)collectionView layout:(UICollectionViewLayout *)collectionViewLayout +referenceSizeForHeaderInSection:(NSInteger)section { + + CGSize parentSize = self.avatarCollectionView.bounds.size; + return CGSizeMake( parentSize.width / 4, parentSize.height ); +} + +- (CGSize) collectionView:(UICollectionView *)collectionView layout:(UICollectionViewLayout *)collectionViewLayout +referenceSizeForFooterInSection:(NSInteger)section { + + CGSize parentSize = self.avatarCollectionView.bounds.size; + return CGSizeMake( parentSize.width / 4, parentSize.height ); +} + - (CGSize)collectionView:(UICollectionView *)collectionView layout:(UICollectionViewLayout *)collectionViewLayout sizeForItemAtIndexPath:(NSIndexPath *)indexPath { - if (collectionView == self.avatarCollectionView) { - CGSize parentSize = self.avatarCollectionView.bounds.size; - return CGSizeMake( parentSize.width / 2, parentSize.height ); - } - - Throw( @"unexpected collection view: %@", collectionView ); + CGSize parentSize = self.avatarCollectionView.bounds.size; + return CGSizeMake( parentSize.width / 2, parentSize.height ); } #pragma mark - UICollectionViewDataSource