From 5a1a06798733009b9c514ec73c188d1809b978e7 Mon Sep 17 00:00:00 2001 From: Ivan <6350992+bivant@users.noreply.github.com> Date: Tue, 13 Aug 2019 13:01:27 +0300 Subject: [PATCH 1/4] Skip visiblility check (view.window != nil) if non animated viewController change was requested --- Sources/PagerTabStripViewController.swift | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Sources/PagerTabStripViewController.swift b/Sources/PagerTabStripViewController.swift index d7e5551a..fcee54de 100644 --- a/Sources/PagerTabStripViewController.swift +++ b/Sources/PagerTabStripViewController.swift @@ -149,7 +149,7 @@ open class PagerTabStripViewController: UIViewController, UIScrollViewDelegate { } open func moveToViewController(at index: Int, animated: Bool = true) { - guard isViewLoaded && view.window != nil && currentIndex != index else { + guard isViewLoaded && (view.window != nil || animated == false) && currentIndex != index else { preCurrentIndex = index return } From c428dcc180125e0e4db975c1b45278d3d9358504 Mon Sep 17 00:00:00 2001 From: Ivan <6350992+bivant@users.noreply.github.com> Date: Mon, 26 Aug 2019 21:52:24 +0300 Subject: [PATCH 2/4] Fix non animated selected viewController show (was always first one) if the moveTo/moveToViewController was requested prior to the viewDidLoad() -> viewDidLayoutSubviews() --- Sources/PagerTabStripViewController.swift | 3 +++ 1 file changed, 3 insertions(+) diff --git a/Sources/PagerTabStripViewController.swift b/Sources/PagerTabStripViewController.swift index 73de7449..8e177dd8 100644 --- a/Sources/PagerTabStripViewController.swift +++ b/Sources/PagerTabStripViewController.swift @@ -166,6 +166,9 @@ open class PagerTabStripViewController: UIViewController, UIScrollViewDelegate { (navigationController?.view ?? view).isUserInteractionEnabled = !animated containerView.setContentOffset(CGPoint(x: pageOffsetForChild(at: index), y: 0), animated: true) } else { + if(view.window == nil) { + currentIndex = index //in case of bounds change - otherwise the contentOffset is being reset in updateContent() + } (navigationController?.view ?? view).isUserInteractionEnabled = !animated containerView.setContentOffset(CGPoint(x: pageOffsetForChild(at: index), y: 0), animated: animated) } From dfcd7d3701206be1a937eeb9ca84175e58860b00 Mon Sep 17 00:00:00 2001 From: Ivan <6350992+bivant@users.noreply.github.com> Date: Mon, 26 Aug 2019 22:06:25 +0300 Subject: [PATCH 3/4] Code style: tabs -> spaces --- Sources/PagerTabStripViewController.swift | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Sources/PagerTabStripViewController.swift b/Sources/PagerTabStripViewController.swift index 8e177dd8..3bc3cabd 100644 --- a/Sources/PagerTabStripViewController.swift +++ b/Sources/PagerTabStripViewController.swift @@ -166,9 +166,9 @@ open class PagerTabStripViewController: UIViewController, UIScrollViewDelegate { (navigationController?.view ?? view).isUserInteractionEnabled = !animated containerView.setContentOffset(CGPoint(x: pageOffsetForChild(at: index), y: 0), animated: true) } else { - if(view.window == nil) { - currentIndex = index //in case of bounds change - otherwise the contentOffset is being reset in updateContent() - } + if(view.window == nil) { + currentIndex = index //in case of bounds change - otherwise the contentOffset is being reset in updateContent() + } (navigationController?.view ?? view).isUserInteractionEnabled = !animated containerView.setContentOffset(CGPoint(x: pageOffsetForChild(at: index), y: 0), animated: animated) } From 434ba29a74316f6375610f3e01bbd8442401e2f0 Mon Sep 17 00:00:00 2001 From: Ivan <6350992+bivant@users.noreply.github.com> Date: Tue, 27 Aug 2019 14:52:08 +0300 Subject: [PATCH 4/4] #2, addition to c428dcc180125e0e4db975c1b45278d3d9358504 : Fix non animated selected viewController show (was always first one) if the moveTo/moveToViewController was requested prior to the viewDidLoad() -> viewDidLayoutSubviews() --- Sources/PagerTabStripViewController.swift | 1 + 1 file changed, 1 insertion(+) diff --git a/Sources/PagerTabStripViewController.swift b/Sources/PagerTabStripViewController.swift index 3bc3cabd..94ad0c99 100644 --- a/Sources/PagerTabStripViewController.swift +++ b/Sources/PagerTabStripViewController.swift @@ -167,6 +167,7 @@ open class PagerTabStripViewController: UIViewController, UIScrollViewDelegate { containerView.setContentOffset(CGPoint(x: pageOffsetForChild(at: index), y: 0), animated: true) } else { if(view.window == nil) { + preCurrentIndex = index currentIndex = index //in case of bounds change - otherwise the contentOffset is being reset in updateContent() } (navigationController?.view ?? view).isUserInteractionEnabled = !animated