5

I have been following the XLpagerTabStrip cocoapods extension to set up a tab bar at the top of my view controller (https://github.com/xmartlabs/XLPagerTabStrip). I am implementing the ButtonBarPagerTabStripViewController and have followed the steps exactly, but the UIScrollView is not displaying the child view controllers.

I think this is because in the example the child view controllers are set up programmatically rather than in the storyboard, whereas mine are currently set up in the storyboard, and hence are displaying no content, yet there is no way that I can see to connect the child view controllers to the ButtonBarController via the storyboard.

Is there a way to display the child view controllers using the storyboard, or must it be done programmatically?

The GitHub page says to implement the following function (But this doesnt seem to work if your child view controllers are set up via the storyboard):

override public func viewControllersForPagerTabStrip(pagerTabStripController: PagerTabStripViewController) -> [UIViewController]
 {
  return [MyChildViewController(), MySecondChildViewController()]
}
Ryan Hampton
  • 319
  • 3
  • 20
  • Just get controllers from storyboards using identifiers and then add them programmatically. – tbilopavlovic Jun 13 '16 at 12:02
  • I currently have the: override public func viewControllersForPagerTabStrip(pagerTabStripController: PagerTabStripViewController) -> [UIViewController] { return [MyChildViewController(), MySecondChildViewController()]. But this doesnt seem to be working if you have set up the view controllers via the storyboard – Ryan Hampton Jun 13 '16 at 12:07
  • Please edit the question and paste code from that class – tbilopavlovic Jun 13 '16 at 12:09

1 Answers1

6

You need to load controller from storybard:

override public func viewControllersForPagerTabStrip(pagerTabStripController: PagerTabStripViewController) -> [UIViewController]
{
    let storyboard = UIStoryboard(name: "Main", bundle: nil) 
    let childOneVC = storyboard.instantiateViewControllerWithIdentifier("childOneVC")
    let childTwoVC = storyboard.instantiateViewControllerWithIdentifier("childTwoVC")
    return [childOneVC, childTwoVC]
}
tbilopavlovic
  • 1,059
  • 7
  • 13