i'm working with the third party lib XLPagerTabBarStrip
. it has delegate
override func viewControllers(for pagerTabStripController: PagerTabStripViewController) -> [UIViewController]
Now i'm trying to pass my array that contains the storyboard identifiers names. I'm running for loop to get the name and than pass that to my return statement. When i run the app it shows only last item of array. How can i pass all items of array to the return statement? My code is this,
var child1 = UIViewController()
override func viewControllers(for pagerTabStripController: PagerTabStripViewController) -> [UIViewController] {
let viewController = ["LoggedInVC","RegisterationVC"]
for items in viewController{
child1 = UIStoryboard(name: "Main", bundle: nil).instantiateViewController(withIdentifier: items)
}
return [child1]
}
When i run the app it only shows vc with identifier RegisterationVC
. How can i show both at once?
Your var child1
is of type UIViewController
and you override this variable every time your loop is executed.
What you need is an Array of UIViewController
Try this:
override func viewControllers(for pagerTabStripController: PagerTabStripViewController) -> [UIViewController] {
var childs = Array<UIViewController>()
let viewControllers = ["LoggedInVC","RegisterationVC"]
for item in viewControllers {
childs.append(UIStoryboard(name: "Main", bundle: nil).instantiateViewController(withIdentifier: item))
}
return childs
}