【问题标题】:Swift: UIScrollView not displaying child view controller using XLPagerTabStripSwift:UIScrollView 不使用 XLPagerTabStrip 显示子视图控制器
【发布时间】:2016-06-12 13:22:19
【问题描述】:

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

【问题讨论】:

    标签: ios swift uiscrollview xlpagertabstrip


    【解决方案1】:

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

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

    }

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

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2016-10-13
      • 1970-01-01
      • 2016-10-22
      • 1970-01-01
      • 1970-01-01
      • 2019-08-20
      • 1970-01-01
      相关资源
      最近更新 更多