我收到了2个崩溃报告,其中后面的痕迹似乎表明在故事板中解码图像引用时出现问题。据此设备报道
我无法在运行7.1的iPhone 5上运行,也无法在运行7.0的模拟器中重现它。我正在使用7.1 SDK,故事板和资产目录。
第一个日志如下所示:
EXC_BAD_ACCESS KERN_INVALID_ADDRESS at 0x9000000c
Thread : Crashed: com.apple.main-thread
0 libobjc.A.dylib 0x39c9ab66 objc_msgSend + 5
1 CoreGraphics 0x2f9bbc09 CGImageRetain + 16
2 UIKit 0x320d742b -[UIImage initWithCGImage:scale:orientation:] + 114
3 UIKit 0x320d739f +[UIImage imageWithCGImage:scale:orientation:] + 62
4 UIKit 0x320e2c4b -[_UIAssetManager imageNamed:scale:idiom:subtype:cachingOptions:] + 334
5 UIKit 0x320e2af7 -[_UIAssetManager imageNamed:scale:idiom:subtype:] + 38
6 UIKit 0x320e2acd -[_UIAssetManager imageNamed:idiom:subtype:] + 44
...
第二个略有不同:
Thread : Crashed: com.apple.main-thread
0 libobjc.A.dylib 0x39c9ab66 objc_msgSend + 5
1 CoreUI 0x33a7bd0d -[CUIStructuredThemeStore renditionWithKey:] + 1052
2 CoreUI 0x33a850af -[CUINamedImage _renditionForSpecificKey:] + 170
3 CoreUI 0x33a850fd -[CUINamedImage image] + 20
4 UIKit 0x320e2c01 -[_UIAssetManager imageNamed:scale:idiom:subtype:cachingOptions:] + 260
5 UIKit 0x320e2af7 -[_UIAssetManager imageNamed:scale:idiom:subtype:] + 38
6 UIKit 0x320e2acd -[_UIAssetManager imageNamed:idiom:subtype:] + 44
从第6行开始的其余跟踪对于两个崩溃日志都是通用的。
7 UIKit 0x320e2a9b -[_UIAssetManager imageNamed:idiom:] + 46
8 UIKit 0x32427ab1 -[UIImageNibPlaceholder initWithCoder:] + 288
9 UIKit 0x324bd1d9 UINibDecoderDecodeObjectForValue + 740
10 UIKit 0x324bceef -[UINibDecoder decodeObjectForKey:] + 90
11 UIKit 0x3241b4bd -[UIButtonContent initWithCoder:] + 296
12 UIKit 0x324bd1d9 UINibDecoderDecodeObjectForValue + 740
13 UIKit 0x324bd557 UINibDecoderDecodeObjectForValue + 1634
14 UIKit 0x324bceef -[UINibDecoder decodeObjectForKey:] + 90
15 UIKit 0x3241d613 -[UIButton initWithCoder:] + 594
16 UIKit 0x324bd1d9 UINibDecoderDecodeObjectForValue + 740
17 UIKit 0x324bceef -[UINibDecoder decodeObjectForKey:] + 90
18 UIKit 0x32426bf9 -[UIRuntimeConnection initWithCoder:] + 112
19 UIKit 0x3242723f -[UIRuntimeEventConnection initWithCoder:] + 42
20 UIKit 0x324bd1d9 UINibDecoderDecodeObjectForValue + 740
21 UIKit 0x324bd179 UINibDecoderDecodeObjectForValue + 644
22 UIKit 0x324bceef -[UINibDecoder decodeObjectForKey:] + 90
23 UIKit 0x324263f5 -[UINib instantiateWithOwner:options:] + 888
24 UIKit 0x323880fb -[UIViewController _loadViewFromNibNamed:bundle:] + 234
25 UIKit 0x321e9b59 -[UIViewController loadView] + 92
26 UIKit 0x320cb79d -[UIViewController loadViewIfRequired] + 72
27 UIKit 0x320cb719 -[UIViewController view] + 24
28 UIKit 0x321412a3 -[UIViewController viewControllerForRotation] + 58
29 UIKit 0x32141209 -[UIViewController _visibleView] + 76
30 UIKit 0x321b0fb5 -[UIWindowController transition:fromViewController:toViewController:target:didEndSelector:animation:] + 4604
31 UIKit 0x321af631 -[UIViewController presentViewController:withTransition:completion:] + 4676
32 FaceInvaders 0x0000e885 -[RSHomeViewController tableView:didSelectRowAtIndexPath:] (RSHomeViewController.m:93)
33 UIKit 0x321e40cb -[UITableView _selectRowAtIndexPath:animated:scrollPosition:notifyDelegate:] + 1078
34 UIKit 0x32297863 -[UITableView _userSelectRowAtPendingSelectionIndexPath:] + 214
35 UIKit 0x32147781 _applyBlockToCFArrayCopiedToStack + 316
36 UIKit 0x320bf7bb _afterCACommitHandler + 430
37 CoreFoundation 0x2f90df69 __CFRUNLOOP_IS_CALLING_OUT_TO_AN_OBSERVER_CALLBACK_FUNCTION__ + 20
38 CoreFoundation 0x2f90b8f7 __CFRunLoopDoObservers + 286
39 CoreFoundation 0x2f90bc43 __CFRunLoopRun + 738
40 CoreFoundation 0x2f876471 CFRunLoopRunSpecific + 524
41 CoreFoundation 0x2f876253 CFRunLoopRunInMode + 106
42 GraphicsServices 0x345b02eb GSEventRunModal + 138
43 UIKit 0x3212b845 UIApplicationMain + 1136
44 FaceInvaders 0x00017fa1 main (main.m:16)
可能导致此问题的任何想法或我可以如何调试它?
答案 0 :(得分:2)
我想我发现了这个问题,故事板中包含了这个标记:
<image name="pressed" width="1" height="1"/>
而实际图像为1x80像素。
据推测,某些版本的iOS信任故事板并分配不正确大小的缓冲区,而其他版本则执行某种边界检查。
因此,解决方法是检查故事大小的XML末尾的<resources>
标记是否有不正确的大小。如果有,请删除图像并重新添加。如果这不起作用,请完全删除图像,然后将其加载到代码中。