我一直在关注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")
}


Image showing the connections of the ButtonBarView and UIScrollView

最佳答案

您应该使用故事板!.instantiateViewControllerWithIdentifier
在里面

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


}

如果您使用情节提要和IB,则无需直接初始化ViewController

07-28 03:01