我一直在关注 XLpagerTabStrip cocoapods 扩展以在我的 View Controller (https://github.com/xmartlabs/XLPagerTabStrip) 顶部设置一个选项卡栏。我正在实现 ButtonBarPagerTabStripViewController 并严格按照步骤操作,但 UIScrollView 未显示 subview Controller 。
我认为这是因为在示例中, subview Controller 是通过编程方式设置的,而不是在 Storyboard 中设置的,而我的当前设置在 Storyboard 中,因此没有显示任何内容,但我无法请参阅通过 Storyboard将 subview Controller 连接到 ButtonBarController。
有没有办法使用 Storyboard显示 subview Controller ,还是必须以编程方式完成?
GitHub 页面说要实现以下功能(但如果您的 subview Controller 是通过 Storyboard设置的,这似乎不起作用):
override public func viewControllersForPagerTabStrip(pagerTabStripController: PagerTabStripViewController) -> [UIViewController]
{
return [MyChildViewController(), MySecondChildViewController()]
}
最佳答案
您需要从 Storyboard加载 Controller :
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]
}
关于ios - Swift:如何通过 Storyboard而不是使用 XLPagerTabStrip 以编程方式显示 subview Controller ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37789327/