“TwitterPagerTabStripViewController crash on back navigation” fixed. #178

This commit is contained in:
Martin Barreto 2017-01-26 16:50:20 -03:00
parent 3ecbb5665d
commit bf8edc820b
1 changed files with 4 additions and 5 deletions

View File

@ -87,7 +87,7 @@ open class TwitterPagerTabStripViewController: PagerTabStripViewController, Page
open func updateIndicator(for viewController: PagerTabStripViewController, fromIndex: Int, toIndex: Int, withProgressPercentage progressPercentage: CGFloat, indexWasChanged: Bool) {
// move indicator scroll view
let distance = distanceValue
guard let distance = distanceValue else { return }
var xOffset: CGFloat = 0
if fromIndex < toIndex {
xOffset = distance * CGFloat(fromIndex) + distance * progressPercentage
@ -193,7 +193,7 @@ open class TwitterPagerTabStripViewController: PagerTabStripViewController, Page
}
private func setNavigationViewItemsPosition(updateAlpha: Bool) {
let distance = distanceValue
guard let distance = distanceValue else { return }
let isPortrait = UIApplication.shared.statusBarOrientation.isPortrait
let navBarHeight: CGFloat = navigationController!.navigationBar.frame.size.height
for (index, label) in childTitleLabels.enumerated() {
@ -231,8 +231,7 @@ open class TwitterPagerTabStripViewController: PagerTabStripViewController, Page
}
}
private var distanceValue: CGFloat {
let middle = navigationController!.navigationBar.convert(navigationController!.navigationBar.center, to: titleView)
return middle.x
private var distanceValue: CGFloat? {
return navigationController.map { $0.navigationBar.convert($0.navigationBar.center, to: titleView) }?.x
}
}