From 8cd01639b664596f35551f8acb5d8a6780a0369e Mon Sep 17 00:00:00 2001 From: Martin Barreto Date: Tue, 27 Sep 2016 15:56:04 -0300 Subject: [PATCH 1/2] trying to fix linking error --- Sources/BarPagerTabStripViewController.swift | 2 +- Sources/ButtonBarPagerTabStripViewController.swift | 2 +- Sources/PagerTabStripViewController.swift | 2 +- Sources/SegmentedPagerTabStripViewController.swift | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/Sources/BarPagerTabStripViewController.swift b/Sources/BarPagerTabStripViewController.swift index 06fc7d8..2415ea4 100644 --- a/Sources/BarPagerTabStripViewController.swift +++ b/Sources/BarPagerTabStripViewController.swift @@ -40,7 +40,7 @@ open class BarPagerTabStripViewController: PagerTabStripViewController, PagerTab open var settings = BarPagerTabStripSettings() - @IBOutlet lazy open var barView: BarView! = { [unowned self] in + @IBOutlet lazy public var barView: BarView! = { [unowned self] in let barView = BarView(frame: CGRect(x: 0, y: 0, width: self.view.frame.size.width, height: self.settings.style.barHeight)) barView.autoresizingMask = .flexibleWidth barView.backgroundColor = .black diff --git a/Sources/ButtonBarPagerTabStripViewController.swift b/Sources/ButtonBarPagerTabStripViewController.swift index ee6c559..2a8c6bb 100644 --- a/Sources/ButtonBarPagerTabStripViewController.swift +++ b/Sources/ButtonBarPagerTabStripViewController.swift @@ -68,7 +68,7 @@ open class ButtonBarPagerTabStripViewController: PagerTabStripViewController, Pa open var settings = ButtonBarPagerTabStripSettings() - lazy open var buttonBarItemSpec: ButtonBarItemSpec = .nibFile(nibName: "ButtonCell", bundle: Bundle(for: ButtonBarViewCell.self), width:{ [weak self] (childItemInfo) -> CGFloat in + lazy public var buttonBarItemSpec: ButtonBarItemSpec = .nibFile(nibName: "ButtonCell", bundle: Bundle(for: ButtonBarViewCell.self), width:{ [weak self] (childItemInfo) -> CGFloat in let label = UILabel() label.translatesAutoresizingMaskIntoConstraints = false label.font = self?.settings.style.buttonBarItemFont diff --git a/Sources/PagerTabStripViewController.swift b/Sources/PagerTabStripViewController.swift index 526ebd1..cec7ff9 100644 --- a/Sources/PagerTabStripViewController.swift +++ b/Sources/PagerTabStripViewController.swift @@ -53,7 +53,7 @@ public protocol PagerTabStripDataSource: class { open class PagerTabStripViewController: UIViewController, UIScrollViewDelegate { - @IBOutlet lazy open var containerView: UIScrollView! = { [unowned self] in + @IBOutlet lazy public var containerView: UIScrollView! = { [unowned self] in let containerView = UIScrollView(frame: CGRect(x: 0, y: 0, width: self.view.bounds.width, height: self.view.bounds.height)) containerView.autoresizingMask = [.flexibleWidth, .flexibleHeight] return containerView diff --git a/Sources/SegmentedPagerTabStripViewController.swift b/Sources/SegmentedPagerTabStripViewController.swift index def877a..817baf6 100644 --- a/Sources/SegmentedPagerTabStripViewController.swift +++ b/Sources/SegmentedPagerTabStripViewController.swift @@ -36,7 +36,7 @@ public struct SegmentedPagerTabStripSettings { open class SegmentedPagerTabStripViewController: PagerTabStripViewController, PagerTabStripDataSource, PagerTabStripDelegate { - @IBOutlet lazy open var segmentedControl: UISegmentedControl! = UISegmentedControl() + @IBOutlet lazy public var segmentedControl: UISegmentedControl! = UISegmentedControl() open var settings = SegmentedPagerTabStripSettings() From eca167e0e3a0f4e0febbe944c03bdf3db18382f4 Mon Sep 17 00:00:00 2001 From: Martin Barreto Date: Tue, 27 Sep 2016 16:39:32 -0300 Subject: [PATCH 2/2] trying to fix carthage issue #227. --- .../AppIcon.appiconset/Contents.json | 10 +++ .../SpotifyExampleViewController.swift | 6 +- Sources/BarPagerTabStripViewController.swift | 34 ++++----- ...ButtonBarPagerTabStripViewController.swift | 52 +++++++------- ...ButtonBarPagerTabStripViewController.swift | 71 ++++++++++--------- Sources/ButtonBarView.swift | 2 +- Sources/PagerTabStripViewController.swift | 18 ++--- ...SegmentedPagerTabStripViewController.swift | 3 +- .../TwitterPagerTabStripViewController.swift | 4 +- XLPagerTabStrip.xcodeproj/project.pbxproj | 4 +- 10 files changed, 113 insertions(+), 91 deletions(-) diff --git a/Example/Example/Assets.xcassets/AppIcon.appiconset/Contents.json b/Example/Example/Assets.xcassets/AppIcon.appiconset/Contents.json index 118c98f..b8236c6 100644 --- a/Example/Example/Assets.xcassets/AppIcon.appiconset/Contents.json +++ b/Example/Example/Assets.xcassets/AppIcon.appiconset/Contents.json @@ -1,5 +1,15 @@ { "images" : [ + { + "idiom" : "iphone", + "size" : "20x20", + "scale" : "2x" + }, + { + "idiom" : "iphone", + "size" : "20x20", + "scale" : "3x" + }, { "idiom" : "iphone", "size" : "29x29", diff --git a/Example/Example/Spotify/SpotifyExampleViewController.swift b/Example/Example/Spotify/SpotifyExampleViewController.swift index c1ed4c2..81f4009 100644 --- a/Example/Example/Spotify/SpotifyExampleViewController.swift +++ b/Example/Example/Spotify/SpotifyExampleViewController.swift @@ -25,14 +25,14 @@ import Foundation import XLPagerTabStrip -open class SpotifyExampleViewController: ButtonBarPagerTabStripViewController { +class SpotifyExampleViewController: ButtonBarPagerTabStripViewController { @IBOutlet weak var shadowView: UIView! let graySpotifyColor = UIColor(red: 21/255.0, green: 21/255.0, blue: 24/255.0, alpha: 1.0) let darkGraySpotifyColor = UIColor(red: 19/255.0, green: 20/255.0, blue: 20/255.0, alpha: 1.0) - open override func viewDidLoad() { + override func viewDidLoad() { // change selected bar color settings.style.buttonBarBackgroundColor = graySpotifyColor settings.style.buttonBarItemBackgroundColor = graySpotifyColor @@ -56,7 +56,7 @@ open class SpotifyExampleViewController: ButtonBarPagerTabStripViewController { // MARK: - PagerTabStripDataSource - open override func viewControllers(for pagerTabStripController: PagerTabStripViewController) -> [UIViewController] { + override func viewControllers(for pagerTabStripController: PagerTabStripViewController) -> [UIViewController] { let child_1 = TableChildExampleViewController(style: .plain, itemInfo: IndicatorInfo(title: "FRIENDS")) child_1.blackTheme = true let child_2 = TableChildExampleViewController(style: .plain, itemInfo: IndicatorInfo(title: "FEATURED")) diff --git a/Sources/BarPagerTabStripViewController.swift b/Sources/BarPagerTabStripViewController.swift index 2415ea4..98d22e3 100644 --- a/Sources/BarPagerTabStripViewController.swift +++ b/Sources/BarPagerTabStripViewController.swift @@ -38,15 +38,15 @@ public struct BarPagerTabStripSettings { open class BarPagerTabStripViewController: PagerTabStripViewController, PagerTabStripDataSource, PagerTabStripIsProgressiveDelegate { - open var settings = BarPagerTabStripSettings() + public var settings = BarPagerTabStripSettings() - @IBOutlet lazy public var barView: BarView! = { [unowned self] in - let barView = BarView(frame: CGRect(x: 0, y: 0, width: self.view.frame.size.width, height: self.settings.style.barHeight)) - barView.autoresizingMask = .flexibleWidth - barView.backgroundColor = .black - barView.selectedBar.backgroundColor = .white - return barView - }() + @IBOutlet weak public var barView: BarView! + + required public init?(coder aDecoder: NSCoder) { + super.init(coder: aDecoder) + delegate = self + datasource = self + } public override init(nibName nibNameOrNil: String?, bundle nibBundleOrNil: Bundle?) { super.init(nibName: nibNameOrNil, bundle: nibBundleOrNil) @@ -56,14 +56,16 @@ open class BarPagerTabStripViewController: PagerTabStripViewController, PagerTab open override func viewDidLoad() { super.viewDidLoad() - barView.backgroundColor = self.settings.style.barBackgroundColor ?? barView.backgroundColor - barView.selectedBar.backgroundColor = self.settings.style.selectedBarBackgroundColor ?? barView.selectedBar.backgroundColor - } - - required public init?(coder aDecoder: NSCoder) { - super.init(coder: aDecoder) - delegate = self - datasource = self + barView = barView ?? { + let barView = BarView(frame: CGRect(x: 0, y: 0, width: view.frame.size.width, height: settings.style.barHeight)) + barView.autoresizingMask = .flexibleWidth + barView.backgroundColor = .black + barView.selectedBar.backgroundColor = .white + return barView + }() + + barView.backgroundColor = settings.style.barBackgroundColor ?? barView.backgroundColor + barView.selectedBar.backgroundColor = settings.style.selectedBarBackgroundColor ?? barView.selectedBar.backgroundColor } open override func viewWillAppear(_ animated: Bool) { diff --git a/Sources/BaseButtonBarPagerTabStripViewController.swift b/Sources/BaseButtonBarPagerTabStripViewController.swift index 543d858..f7627e0 100644 --- a/Sources/BaseButtonBarPagerTabStripViewController.swift +++ b/Sources/BaseButtonBarPagerTabStripViewController.swift @@ -26,27 +26,13 @@ import Foundation open class BaseButtonBarPagerTabStripViewController: PagerTabStripViewController, PagerTabStripDataSource, PagerTabStripIsProgressiveDelegate, UICollectionViewDelegate, UICollectionViewDataSource { - open var settings = ButtonBarPagerTabStripSettings() - open var buttonBarItemSpec: ButtonBarItemSpec! - open var changeCurrentIndex: ((_ oldCell: ButtonBarCellType?, _ newCell: ButtonBarCellType?, _ animated: Bool) -> Void)? - open var changeCurrentIndexProgressive: ((_ oldCell: ButtonBarCellType?, _ newCell: ButtonBarCellType?, _ progressPercentage: CGFloat, _ changeCurrentIndex: Bool, _ animated: Bool) -> Void)? + public var settings = ButtonBarPagerTabStripSettings() + public var buttonBarItemSpec: ButtonBarItemSpec! + public var changeCurrentIndex: ((_ oldCell: ButtonBarCellType?, _ newCell: ButtonBarCellType?, _ animated: Bool) -> Void)? + public var changeCurrentIndexProgressive: ((_ oldCell: ButtonBarCellType?, _ newCell: ButtonBarCellType?, _ progressPercentage: CGFloat, _ changeCurrentIndex: Bool, _ animated: Bool) -> Void)? - @IBOutlet open lazy var buttonBarView: ButtonBarView! = { [unowned self] in - var flowLayout = UICollectionViewFlowLayout() - flowLayout.scrollDirection = .horizontal - flowLayout.sectionInset = UIEdgeInsetsMake(0, self.settings.style.buttonBarLeftContentInset ?? 35, 0, self.settings.style.buttonBarRightContentInset ?? 35) - let buttonBarHeight = self.settings.style.buttonBarHeight ?? 44 - let buttonBar = ButtonBarView(frame: CGRect(x: 0, y: 0, width: self.view.frame.size.width, height: buttonBarHeight), collectionViewLayout: flowLayout) - buttonBar.backgroundColor = .orange - buttonBar.selectedBar.backgroundColor = .black - buttonBar.autoresizingMask = .flexibleWidth - var newContainerViewFrame = self.containerView.frame - newContainerViewFrame.origin.y = buttonBarHeight - newContainerViewFrame.size.height = self.containerView.frame.size.height - (buttonBarHeight - self.containerView.frame.origin.y) - self.containerView.frame = newContainerViewFrame - return buttonBar - }() + @IBOutlet public weak var buttonBarView: ButtonBarView! lazy private var cachedCellWidths: [CGFloat]? = { [unowned self] in return self.calculateWidths() @@ -66,7 +52,21 @@ open class BaseButtonBarPagerTabStripViewController [CGFloat] { - let flowLayout = self.buttonBarView.collectionViewLayout as! UICollectionViewFlowLayout - let numberOfCells = self.viewControllers.count + let flowLayout = buttonBarView.collectionViewLayout as! UICollectionViewFlowLayout + let numberOfCells = viewControllers.count var minimumCellWidths = [CGFloat]() var collectionViewContentWidth: CGFloat = 0 - for viewController in self.viewControllers { + for viewController in viewControllers { let childController = viewController as! IndicatorInfoProvider let indicatorInfo = childController.indicatorInfo(for: self) switch buttonBarItemSpec! { @@ -290,14 +290,14 @@ open class BaseButtonBarPagerTabStripViewController = .nibFile(nibName: "ButtonCell", bundle: Bundle(for: ButtonBarViewCell.self), width:{ [weak self] (childItemInfo) -> CGFloat in - let label = UILabel() - label.translatesAutoresizingMaskIntoConstraints = false - label.font = self?.settings.style.buttonBarItemFont - label.text = childItemInfo.title - let labelSize = label.intrinsicContentSize - return labelSize.width + (self?.settings.style.buttonBarItemLeftRightMargin ?? 8) * 2 - }) + public var buttonBarItemSpec: ButtonBarItemSpec! - open var changeCurrentIndex: ((_ oldCell: ButtonBarViewCell?, _ newCell: ButtonBarViewCell?, _ animated: Bool) -> Void)? - open var changeCurrentIndexProgressive: ((_ oldCell: ButtonBarViewCell?, _ newCell: ButtonBarViewCell?, _ progressPercentage: CGFloat, _ changeCurrentIndex: Bool, _ animated: Bool) -> Void)? + public var changeCurrentIndex: ((_ oldCell: ButtonBarViewCell?, _ newCell: ButtonBarViewCell?, _ animated: Bool) -> Void)? + public var changeCurrentIndexProgressive: ((_ oldCell: ButtonBarViewCell?, _ newCell: ButtonBarViewCell?, _ progressPercentage: CGFloat, _ changeCurrentIndex: Bool, _ animated: Bool) -> Void)? - @IBOutlet open lazy var buttonBarView: ButtonBarView! = { [unowned self] in - var flowLayout = UICollectionViewFlowLayout() - flowLayout.scrollDirection = .horizontal - let buttonBarHeight = self.settings.style.buttonBarHeight ?? 44 - let buttonBar = ButtonBarView(frame: CGRect(x: 0, y: 0, width: self.view.frame.size.width, height: buttonBarHeight), collectionViewLayout: flowLayout) - buttonBar.backgroundColor = .orange - buttonBar.selectedBar.backgroundColor = .black - buttonBar.autoresizingMask = .flexibleWidth - var newContainerViewFrame = self.containerView.frame - newContainerViewFrame.origin.y = buttonBarHeight - newContainerViewFrame.size.height = self.containerView.frame.size.height - (buttonBarHeight - self.containerView.frame.origin.y) - self.containerView.frame = newContainerViewFrame - return buttonBar - }() + @IBOutlet public weak var buttonBarView: ButtonBarView! lazy private var cachedCellWidths: [CGFloat]? = { [unowned self] in return self.calculateWidths() @@ -113,6 +93,31 @@ open class ButtonBarPagerTabStripViewController: PagerTabStripViewController, Pa open override func viewDidLoad() { super.viewDidLoad() + buttonBarItemSpec = .nibFile(nibName: "ButtonCell", bundle: Bundle(for: ButtonBarViewCell.self), width:{ [weak self] (childItemInfo) -> CGFloat in + let label = UILabel() + label.translatesAutoresizingMaskIntoConstraints = false + label.font = self?.settings.style.buttonBarItemFont + label.text = childItemInfo.title + let labelSize = label.intrinsicContentSize + return labelSize.width + (self?.settings.style.buttonBarItemLeftRightMargin ?? 8) * 2 + }) + + + let buttonBarViewAux = buttonBarView ?? { + let flowLayout = UICollectionViewFlowLayout() + flowLayout.scrollDirection = .horizontal + let buttonBarHeight = settings.style.buttonBarHeight ?? 44 + let buttonBar = ButtonBarView(frame: CGRect(x: 0, y: 0, width: view.frame.size.width, height: buttonBarHeight), collectionViewLayout: flowLayout) + buttonBar.backgroundColor = .orange + buttonBar.selectedBar.backgroundColor = .black + buttonBar.autoresizingMask = .flexibleWidth + var newContainerViewFrame = containerView.frame + newContainerViewFrame.origin.y = buttonBarHeight + newContainerViewFrame.size.height = containerView.frame.size.height - (buttonBarHeight - containerView.frame.origin.y) + containerView.frame = newContainerViewFrame + return buttonBar + }() + buttonBarView = buttonBarViewAux if buttonBarView.superview == nil { view.addSubview(buttonBarView) @@ -129,7 +134,7 @@ open class ButtonBarPagerTabStripViewController: PagerTabStripViewController, Pa flowLayout.minimumInteritemSpacing = 0 flowLayout.minimumLineSpacing = settings.style.buttonBarMinimumLineSpacing ?? flowLayout.minimumLineSpacing let sectionInset = flowLayout.sectionInset - flowLayout.sectionInset = UIEdgeInsetsMake(sectionInset.top, self.settings.style.buttonBarLeftContentInset ?? sectionInset.left, sectionInset.bottom, self.settings.style.buttonBarRightContentInset ?? sectionInset.right) + flowLayout.sectionInset = UIEdgeInsetsMake(sectionInset.top, settings.style.buttonBarLeftContentInset ?? sectionInset.left, sectionInset.bottom, settings.style.buttonBarRightContentInset ?? sectionInset.right) buttonBarView.showsHorizontalScrollIndicator = false buttonBarView.backgroundColor = settings.style.buttonBarBackgroundColor ?? buttonBarView.backgroundColor @@ -137,7 +142,7 @@ open class ButtonBarPagerTabStripViewController: PagerTabStripViewController, Pa buttonBarView.selectedBarHeight = settings.style.selectedBarHeight // register button bar item cell - switch buttonBarItemSpec { + switch buttonBarItemSpec! { case .nibFile(let nibName, let bundle, _): buttonBarView.register(UINib(nibName: nibName, bundle: bundle), forCellWithReuseIdentifier:"Cell") case .cellClass: @@ -310,16 +315,16 @@ open class ButtonBarPagerTabStripViewController: PagerTabStripViewController, Pa } private func calculateWidths() -> [CGFloat] { - let flowLayout = self.buttonBarView.collectionViewLayout as! UICollectionViewFlowLayout - let numberOfCells = self.viewControllers.count + let flowLayout = buttonBarView.collectionViewLayout as! UICollectionViewFlowLayout + let numberOfCells = viewControllers.count var minimumCellWidths = [CGFloat]() var collectionViewContentWidth: CGFloat = 0 - for viewController in self.viewControllers { + for viewController in viewControllers { let childController = viewController as! IndicatorInfoProvider let indicatorInfo = childController.indicatorInfo(for: self) - switch buttonBarItemSpec { + switch buttonBarItemSpec! { case .cellClass(let widthCallback): let width = widthCallback(indicatorInfo) minimumCellWidths.append(width) @@ -334,14 +339,14 @@ open class ButtonBarPagerTabStripViewController: PagerTabStripViewController, Pa let cellSpacingTotal = CGFloat(numberOfCells - 1) * flowLayout.minimumLineSpacing collectionViewContentWidth += cellSpacingTotal - let collectionViewAvailableVisibleWidth = self.buttonBarView.frame.size.width - flowLayout.sectionInset.left - flowLayout.sectionInset.right + let collectionViewAvailableVisibleWidth = buttonBarView.frame.size.width - flowLayout.sectionInset.left - flowLayout.sectionInset.right if !settings.style.buttonBarItemsShouldFillAvailiableWidth || collectionViewAvailableVisibleWidth < collectionViewContentWidth { return minimumCellWidths } else { let stretchedCellWidthIfAllEqual = (collectionViewAvailableVisibleWidth - cellSpacingTotal) / CGFloat(numberOfCells) - let generalMinimumCellWidth = self.calculateStretchedCellWidths(minimumCellWidths, suggestedStretchedCellWidth: stretchedCellWidthIfAllEqual, previousNumberOfLargeCells: 0) + let generalMinimumCellWidth = calculateStretchedCellWidths(minimumCellWidths, suggestedStretchedCellWidth: stretchedCellWidthIfAllEqual, previousNumberOfLargeCells: 0) var stretchedCellWidths = [CGFloat]() for minimumCellWidthValue in minimumCellWidths { diff --git a/Sources/ButtonBarView.swift b/Sources/ButtonBarView.swift index ceb4219..9f63c0a 100644 --- a/Sources/ButtonBarView.swift +++ b/Sources/ButtonBarView.swift @@ -47,7 +47,7 @@ open class ButtonBarView: UICollectionView { internal var selectedBarHeight: CGFloat = 4 { didSet { - self.updateSlectedBarYPosition() + updateSlectedBarYPosition() } } var selectedBarAlignment: SelectedBarAlignment = .center diff --git a/Sources/PagerTabStripViewController.swift b/Sources/PagerTabStripViewController.swift index cec7ff9..4243e9a 100644 --- a/Sources/PagerTabStripViewController.swift +++ b/Sources/PagerTabStripViewController.swift @@ -53,11 +53,7 @@ public protocol PagerTabStripDataSource: class { open class PagerTabStripViewController: UIViewController, UIScrollViewDelegate { - @IBOutlet lazy public var containerView: UIScrollView! = { [unowned self] in - let containerView = UIScrollView(frame: CGRect(x: 0, y: 0, width: self.view.bounds.width, height: self.view.bounds.height)) - containerView.autoresizingMask = [.flexibleWidth, .flexibleHeight] - return containerView - }() + @IBOutlet weak public var containerView: UIScrollView! open weak var delegate: PagerTabStripDelegate? open weak var datasource: PagerTabStripDataSource? @@ -91,6 +87,12 @@ open class PagerTabStripViewController: UIViewController, UIScrollViewDelegate { override open func viewDidLoad() { super.viewDidLoad() + let conteinerViewAux = containerView ?? { + let containerView = UIScrollView(frame: CGRect(x: 0, y: 0, width: view.bounds.width, height: view.bounds.height)) + containerView.autoresizingMask = [.flexibleWidth, .flexibleHeight] + return containerView + }() + containerView = conteinerViewAux if containerView.superview == nil { view.addSubview(containerView) } @@ -152,7 +154,7 @@ open class PagerTabStripViewController: UIViewController, UIScrollViewDelegate { //MARK: - PagerTabStripDataSource open func viewControllers(for pagerTabStripController: PagerTabStripViewController) -> [UIViewController] { - assertionFailure("Sub-class must implement the PagerTabStripDataSource viewControllersForPagerTabStrip: method") + assertionFailure("Sub-class must implement the PagerTabStripDataSource viewControllers(for:) method") return [] } @@ -359,9 +361,9 @@ open class PagerTabStripViewController: UIViewController, UIScrollViewDelegate { viewControllers = dataSource.viewControllers(for: self) // viewControllers guard viewControllers.count != 0 else { - fatalError("viewControllersForPagerTabStrip should provide at least one child view controller") + fatalError("viewControllers(for:) should provide at least one child view controller") } - viewControllers.forEach { if !($0 is IndicatorInfoProvider) { fatalError("Every view controller provided by PagerTabStripDataSource's viewControllersForPagerTabStrip method must conform to InfoProvider") }} + viewControllers.forEach { if !($0 is IndicatorInfoProvider) { fatalError("Every view controller provided by PagerTabStripDataSource's viewControllers(for:) method must conform to InfoProvider") }} } diff --git a/Sources/SegmentedPagerTabStripViewController.swift b/Sources/SegmentedPagerTabStripViewController.swift index 817baf6..d644beb 100644 --- a/Sources/SegmentedPagerTabStripViewController.swift +++ b/Sources/SegmentedPagerTabStripViewController.swift @@ -36,7 +36,7 @@ public struct SegmentedPagerTabStripSettings { open class SegmentedPagerTabStripViewController: PagerTabStripViewController, PagerTabStripDataSource, PagerTabStripDelegate { - @IBOutlet lazy public var segmentedControl: UISegmentedControl! = UISegmentedControl() + @IBOutlet weak public var segmentedControl: UISegmentedControl! open var settings = SegmentedPagerTabStripSettings() @@ -58,6 +58,7 @@ open class SegmentedPagerTabStripViewController: PagerTabStripViewController, Pa open override func viewDidLoad() { super.viewDidLoad() + segmentedControl = segmentedControl ?? UISegmentedControl() if segmentedControl.superview == nil { navigationItem.titleView = segmentedControl } diff --git a/Sources/TwitterPagerTabStripViewController.swift b/Sources/TwitterPagerTabStripViewController.swift index ed4f0ba..e8093b4 100644 --- a/Sources/TwitterPagerTabStripViewController.swift +++ b/Sources/TwitterPagerTabStripViewController.swift @@ -124,7 +124,9 @@ open class TwitterPagerTabStripViewController: PagerTabStripViewController, Page } deinit { - titleView.removeObserver(self, forKeyPath: "frame") + if isViewLoaded { + titleView.removeObserver(self, forKeyPath: "frame") + } } open override func viewDidLayoutSubviews() { diff --git a/XLPagerTabStrip.xcodeproj/project.pbxproj b/XLPagerTabStrip.xcodeproj/project.pbxproj index 420d602..1bf9ab4 100644 --- a/XLPagerTabStrip.xcodeproj/project.pbxproj +++ b/XLPagerTabStrip.xcodeproj/project.pbxproj @@ -3,7 +3,7 @@ archiveVersion = 1; classes = { }; - objectVersion = 46; + objectVersion = 48; objects = { /* Begin PBXBuildFile section */ @@ -240,7 +240,7 @@ }; }; buildConfigurationList = 28F828771C494B2C00330CF4 /* Build configuration list for PBXProject "XLPagerTabStrip" */; - compatibilityVersion = "Xcode 3.2"; + compatibilityVersion = "Xcode 8.0"; developmentRegion = English; hasScannedForEncodings = 0; knownRegions = (