无法通过 Swift 中的委托调用协议方法

Cannot call the protocol method via delegate in Swift

我在 Swift SPSegment 中使用了一个库,但我无法将它导入我当前的项目 (Swift)

有什么方法可以导入吗?

class TestMain: UIViewController,UITableViewDelegate,UITableViewDataSource, SPSegmentControlCellStyleDelegate, SPSegmentControlDelegate 

它给我这样的错误:

Use of undeclared type 'SPSegmentControlDelegate

但它在示例项目中工作正常

将该库导入您的 viewcontrollerBuild 您的项目

import SPSegmentedControl

从代码中看到,是一个使用了Sparrow的示例项目,你的项目中必须使用sparrow文件夹才行。

下载 Sparrow 并将提取的文件夹拖放到您的项目中

问题是您无法将 SPSegment 作为库导入,因为如果您查看它的内部,它是作为单个项目构建的,而不是作为库构建的。您可以做的是在 SPSegment 中创建您的项目。 只需添加其他 类 和视图,具体取决于您的请求

终于找到问题的原因

Reason is i can't add SPSegmentedControl in my project target membership in file inspector

check project name in Target membership

添加这个

后它工作正常