From 689b312e10fcf1b19ba870ac7227005eb4b57bef Mon Sep 17 00:00:00 2001 From: Alexsander Khitev Date: Sun, 13 Mar 2016 18:56:49 +0400 Subject: [PATCH 1/3] I fixed the bug which was after the device rotation and it showed a wrong image size --- SKPhotoBrowser/SKPhotoBrowser.swift | 26 ++++++++++++++------------ 1 file changed, 14 insertions(+), 12 deletions(-) diff --git a/SKPhotoBrowser/SKPhotoBrowser.swift b/SKPhotoBrowser/SKPhotoBrowser.swift index 5f614b8..661a050 100644 --- a/SKPhotoBrowser/SKPhotoBrowser.swift +++ b/SKPhotoBrowser/SKPhotoBrowser.swift @@ -282,20 +282,22 @@ public class SKPhotoBrowser: UIViewController, UIScrollViewDelegate { isPerformingLayout = true pagingScrollView.frame = frameForPagingScrollView() pagingScrollView.contentSize = contentSizeForPagingScrollView() - + // resize frames of buttons after the device rotation frameForButton() - //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. - // TODO: - need to fix this bug - /*if visiblePages.count > 0 { - let currentIndex = visiblePages.count - 1 - let page = visiblePages[currentIndex] - page.frame = frameForPageAtIndex(currentPageIndex) - page.setMaxMinZoomScalesForCurrentBounds() - if page.captionView != nil { - page.captionView.frame = frameForCaptionView(page.captionView, index: currentIndex) + // this algorithm resizes the current image after device rotation + if visiblePages.count > 0 { + for page in visiblePages { + let pageIndex = page.tag - pageIndexTagOffset + print(pageIndex) + let page = visiblePages[visiblePages.count-1] + page.frame = frameForPageAtIndex(currentPageIndex) + page.setMaxMinZoomScalesForCurrentBounds() + if page.captionView != nil { + page.captionView.frame = frameForCaptionView(page.captionView, index: pageIndex) + } } - }*/ - + } + pagingScrollView.contentOffset = contentOffsetForPageAtIndex(currentPageIndex) // where did start didStartViewingPageAtIndex(currentPageIndex) From cc1aa7d3d44979e39dc3223d05ab2617f04fb9c8 Mon Sep 17 00:00:00 2001 From: Alexsander Khitev Date: Sun, 13 Mar 2016 19:52:24 +0400 Subject: [PATCH 2/3] new algorithm for resize image --- SKPhotoBrowser/SKPhotoBrowser.swift | 5 +---- SKPhotoBrowserExample/SKPhotoBrowserExample/Info.plist | 5 +++-- 2 files changed, 4 insertions(+), 6 deletions(-) diff --git a/SKPhotoBrowser/SKPhotoBrowser.swift b/SKPhotoBrowser/SKPhotoBrowser.swift index 661a050..2f79dd5 100644 --- a/SKPhotoBrowser/SKPhotoBrowser.swift +++ b/SKPhotoBrowser/SKPhotoBrowser.swift @@ -287,13 +287,10 @@ public class SKPhotoBrowser: UIViewController, UIScrollViewDelegate { // this algorithm resizes the current image after device rotation if visiblePages.count > 0 { for page in visiblePages { - let pageIndex = page.tag - pageIndexTagOffset - print(pageIndex) - let page = visiblePages[visiblePages.count-1] page.frame = frameForPageAtIndex(currentPageIndex) page.setMaxMinZoomScalesForCurrentBounds() if page.captionView != nil { - page.captionView.frame = frameForCaptionView(page.captionView, index: pageIndex) + page.captionView.frame = frameForCaptionView(page.captionView, index: currentPageIndex) } } } diff --git a/SKPhotoBrowserExample/SKPhotoBrowserExample/Info.plist b/SKPhotoBrowserExample/SKPhotoBrowserExample/Info.plist index fa8a0ce..3587e98 100644 --- a/SKPhotoBrowserExample/SKPhotoBrowserExample/Info.plist +++ b/SKPhotoBrowserExample/SKPhotoBrowserExample/Info.plist @@ -2,8 +2,6 @@ - UIStatusBarHidden - CFBundleDevelopmentRegion en CFBundleExecutable @@ -32,11 +30,14 @@ armv7 + UIStatusBarHidden + UISupportedInterfaceOrientations UIInterfaceOrientationPortrait UIInterfaceOrientationLandscapeLeft UIInterfaceOrientationLandscapeRight + UIInterfaceOrientationPortraitUpsideDown UISupportedInterfaceOrientations~ipad From d329c86aee60150f089d3bb92ecdfb5f5d0b0b91 Mon Sep 17 00:00:00 2001 From: Alexsander Khitev Date: Sun, 13 Mar 2016 19:58:37 +0400 Subject: [PATCH 3/3] this new algorithm resizes the current image after device rotation --- SKPhotoBrowser.podspec | 2 +- SKPhotoBrowser/SKPhotoBrowser.swift | 5 +++-- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/SKPhotoBrowser.podspec b/SKPhotoBrowser.podspec index bd45c7b..585afaf 100644 --- a/SKPhotoBrowser.podspec +++ b/SKPhotoBrowser.podspec @@ -1,6 +1,6 @@ Pod::Spec.new do |s| s.name = "SKPhotoBrowser" - s.version = "1.6.8" + s.version = "1.6.9" s.summary = "Simple PhotoBrowser/Viewer inspired by facebook, twitter photo browsers written by swift2.0." s.homepage = "https://github.com/suzuki-0000/SKPhotoBrowser" s.license = { :type => "MIT", :file => "LICENSE" } diff --git a/SKPhotoBrowser/SKPhotoBrowser.swift b/SKPhotoBrowser/SKPhotoBrowser.swift index 2f79dd5..5b3ffc0 100644 --- a/SKPhotoBrowser/SKPhotoBrowser.swift +++ b/SKPhotoBrowser/SKPhotoBrowser.swift @@ -287,10 +287,11 @@ public class SKPhotoBrowser: UIViewController, UIScrollViewDelegate { // this algorithm resizes the current image after device rotation if visiblePages.count > 0 { for page in visiblePages { - page.frame = frameForPageAtIndex(currentPageIndex) + let pageIndex = page.tag - pageIndexTagOffset + page.frame = frameForPageAtIndex(pageIndex) page.setMaxMinZoomScalesForCurrentBounds() if page.captionView != nil { - page.captionView.frame = frameForCaptionView(page.captionView, index: currentPageIndex) + page.captionView.frame = frameForCaptionView(page.captionView, index: pageIndex) } } }