gpt4 book ai didi

ios - 在 objc 类中使用 nib 名称初始化 swift View Controller

转载 作者:行者123 更新时间:2023-11-28 09:20:33 29 4
gpt4 key购买 nike

在我的应用程序中,我有一个用 Swift 编写的 View Controller 。我将它导入到用 objective-c 编写的应用程序委托(delegate)中。我尝试像这样创建一个快速 View Controller 的对象

ListAllSongsViewController *songListVC = [[ListAllSongsViewController alloc]initWithNibName:@"ListAllSongsViewController" bundle:nil];

ListAllSongsViewController 是用 swift 编写的。项目编译没有任何问题,但在执行上述行时,应用程序崩溃并停止在 ListAllSongsViewController

的 init 方法处

The crash

日志中没有任何内容,它只是停止了。 Zombie & All 异常断点已启用。

附言它只在设备(iOS 7.1)中崩溃,但在模拟器中工作正常

Update : Getting the same issue even if I use the default swift initialiser

ListAllSongsViewController(nibName: "ListAllSongsViewController", bundle: nil)

最佳答案

通常在您传递了错误的 nibName 时发生。考虑到它仅在设备中崩溃,我认为您对字符串 ListAllSongs 的大小写有误,因为 Mac/模拟器的文件系统不区分大小写,而设备不区分大小写。

关于ios - 在 objc 类中使用 nib 名称初始化 swift View Controller ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24992881/

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