From c93491b6b4b2035d33b1c1cf6b590eb6f33e4bbd Mon Sep 17 00:00:00 2001 From: Joan Martin Date: Fri, 17 Oct 2014 15:39:05 +0200 Subject: [PATCH 1/2] Fixing bug on setting initial gallery index --- RMGallery/RMGalleryViewController.m | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/RMGallery/RMGalleryViewController.m b/RMGallery/RMGalleryViewController.m index b1b8a52..6d0e3fb 100644 --- a/RMGallery/RMGalleryViewController.m +++ b/RMGallery/RMGalleryViewController.m @@ -72,9 +72,15 @@ - (void)viewDidLoad [self.view addGestureRecognizer:_tapGestureRecognizer]; } -- (void)viewWillAppear:(BOOL)animated +//- (void)viewWillAppear:(BOOL)animated +//{ +// [super viewWillAppear:animated]; +//} + +- (void)viewDidLayoutSubviews { - [super viewWillAppear:animated]; + [super viewDidLayoutSubviews]; + if (!_initialGalleryIndexSet) { // In case the gallery index was set before the view was loaded From eefd4d7acbcd15d75f87dd419d10ccf21b297557 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jordi=20Gim=C3=A9nez=20G=C3=A1mez?= Date: Mon, 18 Dec 2017 12:46:21 +0100 Subject: [PATCH 2/2] Fixing images not lazy loading when prefetching is enabled --- RMGallery/RMGalleryView.m | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/RMGallery/RMGalleryView.m b/RMGallery/RMGalleryView.m index 0be6330..1bdd4df 100644 --- a/RMGallery/RMGalleryView.m +++ b/RMGallery/RMGalleryView.m @@ -129,13 +129,15 @@ - (NSInteger)collectionView:(UICollectionView *)collectionView numberOfItemsInSe - (UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath { RMGalleryCell *cell = [collectionView dequeueReusableCellWithReuseIdentifier:CellIdentifier forIndexPath:indexPath]; - + NSInteger imageIndex = indexPath.row; + cell.tag = imageIndex; // mark the cell so we're sure it has not been reused when we fill it with the image + [cell.activityIndicatorView startAnimating]; + __block BOOL sync = YES; - [self.galleryDataSource galleryView:self imageForIndex:indexPath.row completion:^(UIImage *image) { + [self.galleryDataSource galleryView:self imageForIndex:imageIndex completion:^(UIImage *image) { // Check if cell was reused - NSIndexPath *currentIndexPath = [self indexPathForCell:cell]; - if (!sync && [indexPath compare:currentIndexPath] != NSOrderedSame) return; + if (!sync && cell.tag != imageIndex) return; [cell.activityIndicatorView stopAnimating]; cell.image = image;