Skip to content
This repository has been archived by the owner on Apr 6, 2020. It is now read-only.

Delay asset controller layout until frame is correct and layout is complete #158

Merged
merged 1 commit into from
Mar 1, 2017
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 6 additions & 2 deletions QBImagePicker/QBAssetsViewController.m
Original file line number Diff line number Diff line change
Expand Up @@ -105,8 +105,12 @@ - (void)viewWillAppear:(BOOL)animated

// Scroll to bottom
if (self.fetchResult.count > 0 && self.isMovingToParentViewController && !self.disableScrollToBottom) {
NSIndexPath *indexPath = [NSIndexPath indexPathForItem:(self.fetchResult.count - 1) inSection:0];
[self.collectionView scrollToItemAtIndexPath:indexPath atScrollPosition:UICollectionViewScrollPositionTop animated:NO];
// when presenting as a .FormSheet on iPad, the frame is not correct until just after viewWillAppear:
// dispatching to the main thread waits one run loop until the frame is update and the layout is complete
dispatch_async(dispatch_get_main_queue(), ^{
NSIndexPath *indexPath = [NSIndexPath indexPathForItem:(self.fetchResult.count - 1) inSection:0];
[self.collectionView scrollToItemAtIndexPath:indexPath atScrollPosition:UICollectionViewScrollPositionTop animated:NO];
});
}
}

Expand Down