iPhone 应用程序仅在 iOS10 时崩溃,无法识别的选择器发送到实例
iPhone app crashes only on iOS10 with unrecognized selector sent to instance
我有一个应用程序在 iOS 9 上的应用程序商店中运行良好。在设备上的 iOS10 测试版和 Xcode 8 模拟器中,它在其中一个时崩溃选项卡被点击。
它因错误而崩溃
[PXPlaceholderView titleLabel]:发送到实例的无法识别的选择器
屏幕 (DiaryItemsViewController) 正在使用引用 PXPlaceholderView(UIView 子 class)的 .xib 文件
PXPlaceholderView 具有似乎不会在 iOS10
上调用的 initWithFrame 和 initWithCoder 方法
在主屏幕(DiaryItemsViewController)中,我可以在PXPlaceholderView 上设置背景,但不能设置outlets
[self.placeholderView setBackgroundColor:[UIColor redColor]]; //works ok
self.placeholderView.titleLabel.text = NSLocalizedString(@"No Diary Entries", nil); //crashes
占位符视图中的插座似乎在 xib 中设置正确,并且在 Xcode 7/ios 9
中找到工作
PXPlaceholderView 是 DiaryItemsViewController 中的一个 outlet
@property (weak, nonatomic) IBOutlet PXPlaceholderView *placeholderView;
我对 iOS10 中导致崩溃的更改感到有点困惑
如果 PXPlaceholderView 是 UIView 的子类,那么它什么时候获得 titleLabel 属性?那是你的问题,因为代码正在向你的 PXPlaceholderView 实例发送 titleLabel 消息,但它没有匹配该名称的 属性。
重命名占位符 class 解决了这个问题
我有一个应用程序在 iOS 9 上的应用程序商店中运行良好。在设备上的 iOS10 测试版和 Xcode 8 模拟器中,它在其中一个时崩溃选项卡被点击。
它因错误而崩溃
[PXPlaceholderView titleLabel]:发送到实例的无法识别的选择器
屏幕 (DiaryItemsViewController) 正在使用引用 PXPlaceholderView(UIView 子 class)的 .xib 文件
在主屏幕(DiaryItemsViewController)中,我可以在PXPlaceholderView 上设置背景,但不能设置outlets
[self.placeholderView setBackgroundColor:[UIColor redColor]]; //works ok
self.placeholderView.titleLabel.text = NSLocalizedString(@"No Diary Entries", nil); //crashes
占位符视图中的插座似乎在 xib 中设置正确,并且在 Xcode 7/ios 9
中找到工作PXPlaceholderView 是 DiaryItemsViewController 中的一个 outlet
@property (weak, nonatomic) IBOutlet PXPlaceholderView *placeholderView;
我对 iOS10 中导致崩溃的更改感到有点困惑
如果 PXPlaceholderView 是 UIView 的子类,那么它什么时候获得 titleLabel 属性?那是你的问题,因为代码正在向你的 PXPlaceholderView 实例发送 titleLabel 消息,但它没有匹配该名称的 属性。
重命名占位符 class 解决了这个问题