Reputation: 115
I have a CollectionView that runs, and a XLPagerTabStrip than also run, but when I integrate my CollectionView inside XLPagerTabStrip in the IndicatorInfoProvider I have this error...
Thanks!
Upvotes: 1
Views: 1278
Reputation: 1
When you do not use storyboard, you can instantiate your class this way:
let child = ChildViewController(nibName: "ChildViewController", bundle: nil)
Upvotes: 0
Reputation: 6957
I had a similar issue. Looks like when you use storyboard you cannot simply create a new instance of the controller and add to the page list. If you create your child views as below, nothing shows.
let child1 = new ChildViewController()
And as all the views on the controller are nil when you try to access them it throws that exception you mentioned in the question.
Instead, you have to create it via storyboard:
let child1 = storyboard!.instantiateViewControllerWithIdentifier("childViewIdentifier") as! ChildViewController
I found this in an issue on their GitHub repository: https://github.com/xmartlabs/XLPagerTabStrip/issues/123
I think it should be mentioned in the main documentation as well. As their example project doesn't use IB to design views, instantiateViewControllerWithIdentifier is not used in that either so it's not very obvious.
Anyway, it solved my problem. Hope it works for you too.
Upvotes: 5
Reputation: 5450
In your class declaration delegate UICollectionView
.
Something like:
class ViewController: UIViewController, UICollectionViewDelegate {...
Upvotes: 0