0

我一直在关注 XLpagerTabStrip cocoapods 扩展,在我的视图控制器顶部设置一个标签栏(https://github.com/xmartlabs/XLPagerTabStrip)。我正在实现 ButtonBarPagerTabStripViewController 并完全按照步骤操作,但 UIScrollView 没有显示子视图控制器。

选项卡式视图控制器中的代码:

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()]
}

子视图控制器中的示例代码:

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")
}

显示 ButtonBarView 和 UIScrollView 连接的图像

4

1 回答 1

0

您应该使用 storyboard!.instantiateViewControllerWithIdentifier 在

    override func viewControllersForPagerTabStrip(pagerTabStripController: PagerTabStripViewController) -> [UIViewController]{

}

如果您使用故事板和 IB,而不是直接初始化 ViewController

于 2016-08-19T05:54:53.977 回答