2

我正在尝试实施 git 项目XLPagerTabStrip

根据该项目,每个控制器必须:

PagerTabStripDataSource 的 viewControllers(for:) 方法提供的每个视图控制器都必须符合InfoProvider

但是下面的代码抛出:does not conform to protocol

extension UserProfileSubController: IndicatorInfoProvider {

    func indicatorInfo(for pagerTabStripController: PagerTabStripViewController) -> IndicatorInfo {

        return IndicatorInfo(title: "UserProfileSubController")
    }
}

在此处输入图像描述

在此处输入图像描述

在此处输入图像描述

如果我想自动修复问题,它会重新实现相同的协议功能,然后抛出无效的重新声明。

在此处输入图像描述

does not conform to protocol如果您的控制器确实符合问题,您如何解决问题?我错过了什么?非常感谢帮助。

PS:我已经清理了项目,构建文件夹,删除了派生数据,重新启动并执行了 pod 更新以及重新安装 pod。

4

3 回答 3

0

检查 IndicatorInfo 类的方法如下:

public struct IndicatorInfo {

    public var title: String?
    public var image: UIImage?
    public var highlightedImage: UIImage?

    public init(title: String?) {
        self.title = title
    }

    public init(image: UIImage?, highlightedImage: UIImage? = nil) {
        self.image = image
        self.highlightedImage = highlightedImage
    }

    public init(title: String?, image: UIImage?, highlightedImage: UIImage? = nil) {
        self.title = title
        self.image = image
        self.highlightedImage = highlightedImage
    }

}

您使用公共协议IndicatorInfo{}而不是 public struct IndicatorInfo{}

我希望你只能在一个类中使用一个协议。

extension YourViewController : IndicatorInfoProvider {

    // MARK: - Top Tab Bar Method - IndicatorInfoProvider
    func indicatorInfo(for pagerTabStripController: PagerTabStripViewController) -> IndicatorInfo {
        return IndicatorInfo(title: "titleStringHere", image: UIImage(named: "Your_Image_Name"))
       /*or   return IndicatorInfo(title: "titleStringHere") */
    }
}
于 2017-11-21T09:11:17.257 回答
0

最后是复制/粘贴/依赖问题。重新开始并删除 pod 和依赖项代码并重新安装最终解决了问题。

于 2017-11-21T16:45:28.803 回答
-1

我不确定这是否可行,但试试这些:

  1. 将代码放在类中而不是扩展中。
  2. 使用这个特定的 podpod 'XLPagerTabStrip', '~> 7.0'
于 2017-11-08T16:53:41.987 回答