From 7f2db66cdc9ec7635c0ccc2ea197e9a68c0c8217 Mon Sep 17 00:00:00 2001 From: Alexsandersky Date: Thu, 10 Mar 2016 11:21:20 +0400 Subject: [PATCH] some fix --- SKPhotoBrowser/SKPhotoBrowser.swift | 21 +++++++++++++++------ 1 file changed, 15 insertions(+), 6 deletions(-) diff --git a/SKPhotoBrowser/SKPhotoBrowser.swift b/SKPhotoBrowser/SKPhotoBrowser.swift index 9a98084..40fe739 100644 --- a/SKPhotoBrowser/SKPhotoBrowser.swift +++ b/SKPhotoBrowser/SKPhotoBrowser.swift @@ -276,13 +276,22 @@ public class SKPhotoBrowser: UIViewController, UIScrollViewDelegate { pagingScrollView.frame = frameForPagingScrollView() pagingScrollView.contentSize = contentSizeForPagingScrollView() - + //If we open the SKPhotoBrowser from CollectionView not the first image, we have one element in visiblepages and we should to take 0 element from visibleindex but that we should to use frame we should use currentPageIndex for frame's functions. if visiblePages.count > 0 { - let page = visiblePages[currentPageIndex] - page.frame = frameForPageAtIndex(currentPageIndex) - page.setMaxMinZoomScalesForCurrentBounds() - if page.captionView != nil { - page.captionView.frame = frameForCaptionView(page.captionView, index: currentPageIndex) + if visiblePages.count == 1 { + let page = visiblePages[0] + page.frame = frameForPageAtIndex(currentPageIndex) + page.setMaxMinZoomScalesForCurrentBounds() + if page.captionView != nil { + page.captionView.frame = frameForCaptionView(page.captionView, index: currentPageIndex) + } + } else { + let page = visiblePages[currentPageIndex] + page.frame = frameForPageAtIndex(currentPageIndex) + page.setMaxMinZoomScalesForCurrentBounds() + if page.captionView != nil { + page.captionView.frame = frameForCaptionView(page.captionView, index: currentPageIndex) + } } }