mankee mankee - 1 year ago 59
iOS Question

UICollectionView is nil

I have a UIViewController in storyboard which hosts a collectionView which is referenced using a

. However, now I am placing this inside of a
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
is now

Answer Source

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()