From 3dc83770c3a504eabe2a1cf80d3f029a7d07c2c8 Mon Sep 17 00:00:00 2001 From: Martin Lequeux--Gruninger Date: Mon, 25 Sep 2017 11:51:45 +0200 Subject: [PATCH] Proper Bundle loading when linking with static XLPagerTabStrip --- Sources/BaseButtonBarPagerTabStripViewController.swift | 9 ++++++++- Sources/ButtonBarPagerTabStripViewController.swift | 10 +++++++++- 2 files changed, 17 insertions(+), 2 deletions(-) diff --git a/Sources/BaseButtonBarPagerTabStripViewController.swift b/Sources/BaseButtonBarPagerTabStripViewController.swift index a069b98f..7c52b66c 100644 --- a/Sources/BaseButtonBarPagerTabStripViewController.swift +++ b/Sources/BaseButtonBarPagerTabStripViewController.swift @@ -321,7 +321,14 @@ open class ExampleBaseButtonBarPagerTabStripViewController: BaseButtonBarPagerTa } open func initialize() { - buttonBarItemSpec = .nibFile(nibName: "ButtonCell", bundle: Bundle(for: ButtonBarViewCell.self), width: { [weak self] (childItemInfo) -> CGFloat in + var bundle = Bundle(for: ButtonBarViewCell.self) + if let resourcePath = bundle.path(forResource: "XLPagerTabStrip", ofType: "bundle") { + if let resourcesBundle = Bundle(path: resourcePath) { + bundle = resourcesBundle + } + } + + buttonBarItemSpec = .nibFile(nibName: "ButtonCell", bundle: bundle, width: { [weak self] (childItemInfo) -> CGFloat in let label = UILabel() label.translatesAutoresizingMaskIntoConstraints = false label.font = self?.settings.style.buttonBarItemFont ?? label.font diff --git a/Sources/ButtonBarPagerTabStripViewController.swift b/Sources/ButtonBarPagerTabStripViewController.swift index 8f29bcd8..75896ae5 100644 --- a/Sources/ButtonBarPagerTabStripViewController.swift +++ b/Sources/ButtonBarPagerTabStripViewController.swift @@ -101,7 +101,15 @@ 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 + + var bundle = Bundle(for: ButtonBarViewCell.self) + if let resourcePath = bundle.path(forResource: "XLPagerTabStrip", ofType: "bundle") { + if let resourcesBundle = Bundle(path: resourcePath) { + bundle = resourcesBundle + } + } + + buttonBarItemSpec = .nibFile(nibName: "ButtonCell", bundle: bundle, width: { [weak self] (childItemInfo) -> CGFloat in let label = UILabel() label.translatesAutoresizingMaskIntoConstraints = false label.font = self?.settings.style.buttonBarItemFont