ios - Swift:UIScrollView 不使用 XLPagerTabStrip 显示 subview Controller

标签 ios swift uiscrollview xlpagertabstrip

我一直在遵循 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/

相关文章:

ios - Twilio IP 消息传递 : What is the point of [client handleNotification] in the iOS messaging client API?

ios - 为什么 UIScrollView 不滚动?

json - 如何在 Swift 4 中解析包含字典和数组的 JSON?

ios - UIAppearance,在 Interface Builder 中查看结果?

iphone - 我们可以在 UITableViewCell 中添加 ScrollView 吗?

ios - 可将图像拖动到另一个图像 IOS Swift

java - 将带有自定义参数的 Java 构造函数转换为 Objective-C 代码

ios - 如何确定为什么iOS应用在启动时会在iOS 13上崩溃

swift - mixLatest 在 Just 与 Future 中具有不同的行为

swift - 使用 Collection View 使 View Controller 可滚动