gpt4 book ai didi

objective-c - 从 Swift VC 到 Objective-C VC 的推送/执行 segue 不起作用

转载 作者:行者123 更新时间:2023-11-30 10:36:19 25 4
gpt4 key购买 nike

我的项目是用 Swift 开发的。我们想要添加一项已经在 Objective-C 中实现的功能。当我尝试从 Swift VC 推送到 Objective-C VC 时,我收到以下警告并且推送不成功。

我确认桥接 header 和其他build设置已完美配置。

I have 2 ObjC VC files. One VC is completely designed in code so there is no problem to push to that VC. But, in other is designed in segue that i can't push/show from my Swift VC.

使用导航推送:

让story = UIStoryboard(名称:“Main”, bundle :nil)
让 vc = Story.instantiateViewController(withIdentifier: "XXXViewController") 作为? XXXViewController//vc 总是返回 nil
如果让 vc = vc {
navigationController?.pushViewController(vc,animated: true)//无法编译,因为 vc 为 nil
}

警告:

Unknown class _TtC12ProjectName36XXXViewController in Interface Builder file.

使用 Segue:

self.performSegue(withIdentifier: "HomeToXXXVc", 发件人: self)

错误:

Unknown class _TtC12ProjectName36XXXViewController in Interface Builder file.

*** Terminating app due to uncaught exception 'NSUnknownKeyException', reason: '[< UIViewController 0x10132ef60 > setValue:forUndefinedKey:]: this class is not key value coding-compliant for the key yyyLabel.

//yyyLabel - Objective-C Vc 的导出之一。

最佳答案

我发现您的问题基本上是在界面生成器上。

如果错误是“*** 由于未捕获的异常‘NSUnknownKeyException’而终止应用程序,原因:‘[ setValue:forUndefinedKey:]:此类与键 yyyLabel 的键值编码不兼容。”那么它是您在 xib/storyboard 上删除的代码中的源“yyyLabel”,但您可以在类(class)上访问它。

再次检查你的xib/storyboard中的类,检查outlet没有任何警告。

关于objective-c - 从 Swift VC 到 Objective-C VC 的推送/执行 segue 不起作用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/57916872/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com