From e3b8aa87964c8a1dee835f2460fdf7cc9f46ac00 Mon Sep 17 00:00:00 2001 From: James Frost Date: Mon, 6 Mar 2017 17:40:49 +0000 Subject: [PATCH] Disable refresh animation on initial load. --- Pod/Classes/WPMediaPickerViewController.m | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) diff --git a/Pod/Classes/WPMediaPickerViewController.m b/Pod/Classes/WPMediaPickerViewController.m index 821b4576..7b7aee29 100644 --- a/Pod/Classes/WPMediaPickerViewController.m +++ b/Pod/Classes/WPMediaPickerViewController.m @@ -102,7 +102,7 @@ - (void)viewDidLoad [self.view addGestureRecognizer:self.longPressGestureRecognizer]; } - [self refreshData]; + [self refreshDataAnimated:NO]; } - (void)setupLayout @@ -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) @@ -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;