Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Could not load NIB in bundle: 'NSBundle (loaded)' with name 'ButtonCell' #814

Open
nesalexy opened this issue Jan 17, 2021 · 2 comments
Open

Comments

@nesalexy
Copy link

Hello, i have added XLPagerTabStrip from swift package #771 (comment) .My code looks like this:

import UIKit
import XLPagerTabStrip


class MainVC: ButtonBarPagerTabStripViewController, Storyboarded {
    
    var coordinator: AuthorizedCoordinator?
    
    let blueInstagramColor = UIColor(red: 37/255.0, green: 111/255.0, blue: 206/255.0, alpha: 1.0)
    
    override func viewDidLoad() {
        // change selected bar color
        settings.style.buttonBarBackgroundColor = UIColor.white
        settings.style.buttonBarItemBackgroundColor = UIColor.white
        settings.style.selectedBarBackgroundColor = blueInstagramColor
        //settings.style.buttonBarItemFont = .boldSystemFont(ofSize: 14)
        settings.style.selectedBarHeight = 2.0
        settings.style.buttonBarMinimumLineSpacing = 0
        settings.style.buttonBarItemTitleColor = UIColor.black
        settings.style.buttonBarItemsShouldFillAvailableWidth = true
        settings.style.buttonBarLeftContentInset = 0
        settings.style.buttonBarRightContentInset = 0

        changeCurrentIndexProgressive = { [weak self] (oldCell: ButtonBarViewCell?, newCell: ButtonBarViewCell?, progressPercentage: CGFloat, changeCurrentIndex: Bool, animated: Bool) -> Void in
            guard changeCurrentIndex == true else { return }
            oldCell?.label.textColor = .black
            newCell?.label.textColor = self?.blueInstagramColor
        }
        super.viewDidLoad()
    }
    
    // MARK: - PagerTabStripDataSource
    override func viewControllers(for pagerTabStripController: PagerTabStripViewController) -> [UIViewController] {
        let child_2 = ChildExampleViewController(itemInfo: "YOU")
        let child_1 = ChildExampleViewController(itemInfo: "ME")
        return [child_1, child_2]
    }
    

ChildExampleViewController from XLPagerTabStrip example:

import UIKit
import XLPagerTabStrip

class ChildExampleViewController: UIViewController, IndicatorInfoProvider {

    var itemInfo: IndicatorInfo = "View"

    init(itemInfo: IndicatorInfo) {
        self.itemInfo = itemInfo
        super.init(nibName: nil, bundle: nil)
    }

    required init?(coder aDecoder: NSCoder) {
        fatalError("init(coder:) has not been implemented")
    }

    override func viewDidLoad() {
        super.viewDidLoad()

        let label = UILabel()
        label.translatesAutoresizingMaskIntoConstraints = false
        label.text = "XLPagerTabStrip"

        view.addSubview(label)
        view.backgroundColor = .white

        view.addConstraint(NSLayoutConstraint(item: label, attribute: .centerX, relatedBy: .equal, toItem: view, attribute: .centerX, multiplier: 1, constant: 0))
        view.addConstraint(NSLayoutConstraint(item: label, attribute: .centerY, relatedBy: .equal, toItem: view, attribute: .centerY, multiplier: 1, constant: -50))
    }

    // MARK: - IndicatorInfoProvider

    func indicatorInfo(for pagerTabStripController: PagerTabStripViewController) -> IndicatorInfo {
        return itemInfo
    }
}

My VC in storyboard

1

When i run the project i have en error:
**Thread 1: "Could not load NIB in bundle: 'NSBundle (loaded)' with name 'ButtonCell'"**

Please give to me advice how i can fix this issue

@mikezliu
Copy link

mikezliu commented Jul 6, 2022

Are you using 9.0.0 with Swift 5 support?

@csotiriou
Copy link

I am, and it seems that reverting to 8.1.1 fixed my issue. Probably the library supports swift 5 but my project is old and it doesn't support it yet.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants