我一直在遵循 XLpagerTabStrip cocoapods 扩展在我的 View Controller 顶部设置一个选项卡栏( https://github.com/xmartlabs/XLPagerTabStrip )。 我正在实现 ButtonBarPagerTabStripViewController 并完全按照步骤进行操作,但 UIScrollView 不显示 subview Controller 。
选项卡式 View Controller 中的代码:
import UIKit
import XLPagerTabStrip
class MenuTabStrip: ButtonBarPagerTabStripViewController {
override func viewDidLoad() {
self.settings.style.selectedBarHeight = 5.0
self.settings.style.selectedBarBackgroundColor = UIColor.blueColor()
super.viewDidLoad()
// Do any additional setup after loading the view.
}
override func didReceiveMemoryWarning() {
super.didReceiveMemoryWarning()
// Dispose of any resources that can be recreated.
}
override func viewControllersForPagerTabStrip(pagerTabStripController: PagerTabStripViewController) -> [UIViewController]{
return [Reminders(), testbobViewController()]
}
subview Controller 中的示例代码:
import UIKit
import XLPagerTabStrip
class testbobViewController: UIViewController, IndicatorInfoProvider {
override func viewDidLoad() {
super.viewDidLoad()
// Do any additional setup after loading the view.
}
override func didReceiveMemoryWarning() {
super.didReceiveMemoryWarning()
// Dispose of any resources that can be recreated.
}
func indicatorInfoForPagerTabStrip(pagerTabStripController: PagerTabStripViewController) -> IndicatorInfo {
return IndicatorInfo(title: "test bob")
}
Image showing the connections of the ButtonBarView and UIScrollView
最佳答案
你应该使用storyboard!.instantiateViewControllerWithIdentifier 在
override func viewControllersForPagerTabStrip(pagerTabStripController: PagerTabStripViewController) -> [UIViewController]{
}
如果您使用 Storyboard 和 IB,则不要直接初始化 ViewController
关于ios - Swift:UIScrollView 不使用 XLPagerTabStrip 显示 subview Controller ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37774758/