0

I have a UIViewController in storyboard which hosts a collectionView which is referenced using a IBOutlet. However, now I am placing this inside of a PageViewController and referencing it like this, rather than with the use of a seque :

let initial = FeedCollectionViewController()
let viewControllers = [initial]
setViewControllers(viewControllers, direction: .Forward, animated: true, completion: nil)

The problem is that the collectionView is now nil.

Alk
  • 5,215
  • 8
  • 47
  • 116

1 Answers1

1

Of course it's nil. You built your view controller in storyboard, so you should init it from storyboard. Like this:

let tabSb = UIStoryboard(name: "Main", bundle: nil)
let tabbarVc = tabSb.instantiateInitialViewController()
Lumialxk
  • 6,239
  • 6
  • 24
  • 47
  • Thanks, I managed to solve this, it loads fine however, I have the view embedded in a tab bar controller in my storyboard which is now not visible. – Alk Jul 15 '16 at 00:21