From 896a5c2f52bfbbc9c8a90d08729eacacddafc542 Mon Sep 17 00:00:00 2001 From: Yulia Myhailova Date: Thu, 5 Jun 2014 19:15:19 +0300 Subject: [PATCH] Refs #1 fixed Bug fix of the issue with index change on rotation. --- RMGallery/RMGalleryView.m | 3 +++ RMGallery/RMGalleryViewController.m | 11 +++++++++++ 2 files changed, 14 insertions(+) diff --git a/RMGallery/RMGalleryView.m b/RMGallery/RMGalleryView.m index a97b2ca..0be6330 100644 --- a/RMGallery/RMGalleryView.m +++ b/RMGallery/RMGalleryView.m @@ -204,6 +204,9 @@ -(void)scrollViewWillEndDragging:(UIScrollView*)scrollView withVelocity:(CGPoint - (void)scrollViewDidScroll:(UIScrollView *)scrollView { + if (!self.scrollEnabled) { + return; + } const NSUInteger index = [_imageFlowLayout indexForOffset:scrollView.contentOffset]; if (index != _galleryIndex) { diff --git a/RMGallery/RMGalleryViewController.m b/RMGallery/RMGalleryViewController.m index a8bb934..b1b8a52 100644 --- a/RMGallery/RMGalleryViewController.m +++ b/RMGallery/RMGalleryViewController.m @@ -83,6 +83,17 @@ - (void)viewWillAppear:(BOOL)animated } } +- (void)willRotateToInterfaceOrientation:(UIInterfaceOrientation)orientation + duration:(NSTimeInterval)duration +{ + _galleryView.scrollEnabled = NO; +} + +- (void)didRotateFromInterfaceOrientation:(UIInterfaceOrientation)fromOrientation +{ + _galleryView.scrollEnabled = YES; +} + - (void)willAnimateRotationToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation duration:(NSTimeInterval)duration { [super willAnimateRotationToInterfaceOrientation:toInterfaceOrientation duration:duration];