UIPickerView iOS7.1中的未定义键NSException [英] Undefined key NSException in UIPickerView iOS7.1

查看:116
本文介绍了UIPickerView iOS7.1中的未定义键NSException的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在iOS 7.1模拟器中遇到了一个例外,该例外在7.0中未出现。它似乎在内核中的某个地方处理,因为它仅触发异常引发断点。它不会登录到控制台或崩溃。在UIPickerView中滚动浏览选项时会发生这种情况。没有有意义的回溯可用(从UIApplicationMain到objc_exception_throw),但是在调试器中抛出异常时检查异常:

I'm getting an exception in the iOS 7.1 simulator that doesn't appear in 7.0. It appears to be handled somewhere in the core because it only triggers an exception raise breakpoint. It doesn't log to the console or crash. This occurs while scrolling through options in a UIPickerView. There is no meaningful backtrace available (right from UIApplicationMain into objc_exception_throw), but examining the exception during throw in the debugger shows:

[< UIPickerView 0xb9a6700> valueForUndefinedKey:]:此类不适用于键_mode的键值编码兼容。

我在项目中搜索了 mode setMode: mode = ,但我不认为在这个设置之一。还有其他人遇到吗?我想,如果它没有使应用程序崩溃也可以,但给我带来了恐惧,我宁愿采取行动以防止它被抛出。如果有更多时间,我将尝试在测试项目中将其隔离出来,然后进行后续操作。

I searched in my project for mode, setMode:, mode = but I don't think I'm the one setting this. Anyone else run into this? I guess it's okay if it's not crashing the app but it gave me a scare, and I'd rather take action to prevent it from being thrown. If I have some more time I'll try to isolate this in a test project and follow up.

编辑:更好的回溯:

         thread #1: tid = 0x10975c, 0x02590909 libc++abi.dylib`__cxa_throw, queue = 'com.apple.main-thread, stop reason = breakpoint 1.2
     frame #0: 0x02590909 libc++abi.dylib`__cxa_throw
     frame #1: 0x01b1d9fc libobjc.A.dylib`objc_exception_throw + 323
     frame #2: 0x020e1fe1 CoreFoundation`-[NSException raise] + 17
     frame #3: 0x017ddc7a Foundation`-[NSObject(NSKeyValueCoding) valueForUndefinedKey:] + 282
     frame #4: 0x0174adfd Foundation`_NSGetUsingKeyValueGetter + 81
     frame #5: 0x0174a437 Foundation`-[NSObject(NSKeyValueCoding) valueForKey:] + 260
     frame #6: 0x0d615dff AccessibilityUtilities`-[NSObject(UIAccessibilitySafeCategory) safeValueForKey:] + 43
     frame #7: 0x1151c1f6 UIKit`-[UIAccessibilityPickerComponent accessibilityTraits] + 398
     frame #8: 0x0d716021 UIAccessibility`-[NSObject(AXPrivCategory) accessibilityAttributeValue:] + 1865
     frame #9: 0x0d70a7d7 UIAccessibility`_copyMultipleAttributeValuesCallback + 409
     frame #10: 0x0d76c537 AXRuntime`_AXXMIGCopyMultipleAttributeValues + 202
     frame #11: 0x0d767e78 AXRuntime`_XCopyMultipleAttributeValues + 473
     frame #12: 0x0d7726b4 AXRuntime`mshMIGPerform + 256
     frame #13: 0x01fcdca5 CoreFoundation`__CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE1_PERFORM_FUNCTION__ + 53
     frame #14: 0x01fcd9db CoreFoundation`__CFRunLoopDoSource1 + 523
     frame #15: 0x01ff868c CoreFoundation`__CFRunLoopRun + 2156
     frame #16: 0x01ff79d3 CoreFoundation`CFRunLoopRunSpecific + 467
     frame #17: 0x01ff77eb CoreFoundation`CFRunLoopRunInMode + 123
     frame #18: 0x03fea5ee GraphicsServices`GSEventRunModal + 192
     frame #19: 0x03fea42b GraphicsServices`GSEventRun + 104
     frame #20: 0x007ddf9b UIKit`UIApplicationMain + 1225
     frame #21: 0x0004863d [redacted]`main(argc=1, argv=0xbfffef50) + 141 at main.m:16


推荐答案

就我而言,在Xcode 6.2和iOS 8.2上,只有模拟器崩溃(但可以安全地继续)。由于 _mode 在我们的代码中不存在,因此可以安全地假设存在模拟器错误或配置错误。

In my case, on Xcode 6.2 and iOS 8.2, only simulator crashes (but can safely continue). Since _mode is nowhere within our code, it's probably safe to assume there is a simulator bug or misconfiguration.

对于现在,我在有问题的UIPickerView上使用类别来摆脱烦恼:

For now, I am using a category on the offending UIPickerView to get rid of the annoyance:

#import "UIPickerView+FixCrash.h"

@implementation UIPickerView (FixCrash)

#if TARGET_IPHONE_SIMULATOR
- (id)valueForUndefinedKey:(NSString *)key
{
    return nil;
}
#endif

@end

这篇关于UIPickerView iOS7.1中的未定义键NSException的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆