I'm trying to develop a TableViewController
that shows commands. Every cell of the table is a collectionView
, but I'm wondering if I can programmatically instantiate a storyboard and pass the initial controller (collectionViewController
) to that collectionView
inside a UITableViewCell
this a schema of what I'm trying to do.
The question is: Can I put a storyboard inside a tableViewCell
so I can navigate inside that cell and do stuff ?
solution
override func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
let cell = tableView.dequeueReusableCell(withIdentifier: "cell", for: indexPath)
let st = UIStoryboard(name: "Storyboard", bundle: nil)
let vc = st.instantiateInitialViewController() as! UINavigationController
self.addChildViewController(vc)
vc.view.frame = CGRect(x:0, y:0,width: cell.contentView.frame.size.width, height: 40);
cell.contentView.addSubview((vc.view)!)
vc.didMove(toParentViewController: self)
return cell
}
with Storyboard
is a custom storyboard with navigationController as its first controller