【发布时间】:2016-08-11 00:00:06
【问题描述】:
我有一个 UIButton Swift 子类 CustomButton,我想向 Obj-C 公开一个前缀名称。
@objc(PrefixCustomButton) public class CustomButton: UIButton { ... }
此类存在于 Swift 模块 CustomModule 中。我正在通过 Cocoapods 将此模块集成到 Objective-C 和 Swift 应用程序中以测试 CustomButton。当我尝试使用 Storyboard 中的 CustomButton 时,出现以下错误:
Unknown class _TtC9CustomModule17CustomButton in Interface Builder file.
我也尝试在 Storyboard 中使用 PrefixCustomButton 并得到同样的错误:
Unknown class _TtC9CustomModule22PrefixCustomButton in Interface Builder file.
编辑:@matt 是正确的,PrefixCustomButton 必须在 Storyboard 中使用(对于 Swift 和 Obj-C 项目)。我缺少的附加部分是我不需要设置模块名称。
【问题讨论】:
-
@objc(PrefixCustomButton) CustomButton: UIButton { ... }这不是 Swift。也许你的意思是@objc(PrefixCustomButton) class CustomButton: UIButton { ... } -
是的,抱歉,将编辑!
标签: ios objective-c swift uibutton storyboard