Skip to content
This repository was archived by the owner on Jun 19, 2025. It is now read-only.
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
19 changes: 16 additions & 3 deletions Pod/Classes/WPMediaPickerViewController.m
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ - (void)viewDidLoad
[self.view addGestureRecognizer:self.longPressGestureRecognizer];
}

[self refreshData];
[self refreshDataAnimated:NO];
}

- (void)setupLayout
Expand Down Expand Up @@ -182,11 +182,16 @@ -(NSArray *)indexPathsFromIndexSet:(NSIndexSet *)indexSet section:(NSInteger)sec
}

- (void)refreshData
{
[self refreshDataAnimated:YES];
}

- (void)refreshDataAnimated:(BOOL)animated
{
if (self.refreshGroupFirstTime) {
if (![self.refreshControl isRefreshing]) {
[self.collectionView setContentOffset:CGPointMake(0, - [[self topLayoutGuide] length]) animated:NO];
[self.collectionView setContentOffset:CGPointMake(0, - [[self topLayoutGuide] length] - (self.refreshControl.frame.size.height)) animated:YES];
[self.collectionView setContentOffset:CGPointMake(0, - [[self topLayoutGuide] length] - (self.refreshControl.frame.size.height)) animated:animated];
[self.refreshControl beginRefreshing];
}
// NOTE: Sergio Estevao (2015-11-19)
Expand All @@ -208,7 +213,15 @@ - (void)refreshData
strongSelf.collectionView.allowsMultipleSelection = self.allowMultipleSelection;
strongSelf.collectionView.scrollEnabled = YES;
[strongSelf.collectionView reloadData];
[strongSelf.refreshControl endRefreshing];

if (animated) {
[strongSelf.refreshControl endRefreshing];
} else {
[UIView performWithoutAnimation:^{
[strongSelf.refreshControl endRefreshing];
}];
}

// Scroll to the correct position
if (strongSelf.refreshGroupFirstTime && [strongSelf.dataSource numberOfAssets] > 0){
NSInteger sectionToScroll = 0;
Expand Down