【发布时间】:2015-02-12 19:28:05
【问题描述】:
在 iPad 上运行仅限 iPhone 的应用程序时遇到了问题。崩溃日志中的错误是
Exception Type: EXC_BAD_ACCESS (SIGSEGV)
Exception Subtype: KERN_PROTECTION_FAILURE at 0x00ac3ff8
Triggered by Thread: 0
Thread 0 name: Dispatch queue: com.apple.main-thread
Thread 0 Crashed:
0 libsystem_malloc.dylib 0x38cccdd4 allocate_pages + 352
1 libsystem_malloc.dylib 0x38cccace large_malloc + 70
2 libsystem_malloc.dylib 0x38cc83ee szone_malloc_should_clear + 1362
3 libsystem_malloc.dylib 0x38cc7e68 malloc_zone_malloc + 88
4 CoreFoundation 0x2aa24ea2 __CFStringChangeSizeMultiple + 866
5 CoreFoundation 0x2a983554 CFStringCreateMutableCopy + 408
6 CoreFoundation 0x2a99abba -[__NSCFString mutableCopyWithZone:] + 22
7 MyApp 0x006a274c 0xa3000 + 6289228
8 MyApp 0x006a2a7e 0xa3000 + 6290046
9 MyApp 0x006a2800 0xa3000 + 6289408
10 MyApp 0x006a2a7e 0xa3000 + 6290046
11 MyApp 0x006a2800 0xa3000 + 6289408
12 MyApp 0x006a2a7e 0xa3000 + 6290046
13 MyApp 0x006a2800 0xa3000 + 6289408
14 MyApp 0x006a2a7e 0xa3000 + 6290046
15 MyApp 0x006a2800 0xa3000 + 6289408
16 MyApp 0x006a2a7e 0xa3000 + 6290046
17 MyApp 0x006a2800 0xa3000 + 6289408
18 MyApp 0x006a2a7e 0xa3000 + 6290046
19 MyApp 0x006a2800 0xa3000 + 6289408
20 MyApp 0x006a2a7e 0xa3000 + 6290046
21 MyApp 0x006a2800 0xa3000 + 6289408
22 MyApp 0x006a2a7e 0xa3000 + 6290046
23 MyApp 0x006a2800 0xa3000 + 6289408
24 MyApp 0x006a2a7e 0xa3000 + 6290046
在 XCode 中,由 '[UIImage imageNamed]' 导致的崩溃。这让我很困惑。我想知道如何调试和修复这种错误
更新:
断点停在这行代码
- (UIButton *)customBackButton
{
UIImage *buttonImage = [UIImage imageNamed:@"actionbar_back_nor.png"];
UIImage *buttonImagePressed = [UIImage imageNamed:@"actionbar_back_pre.png"];
UIButton *aButton = [UIButton buttonWithType:UIButtonTypeCustom];
[aButton setImage:buttonImage forState:UIControlStateNormal];
[aButton setImage:buttonImagePressed forState:UIControlStateHighlighted];
aButton.frame = CGRectMake(0.0,0.0,44,44);
UIEdgeInsets insets;
if (IOS_VERSION_7_OR_BETTER) {
insets = UIEdgeInsetsMake(11, 0, 11, 22);
}else{
insets = UIEdgeInsetsMake(11, 11, 11, 11);
}
aButton.imageEdgeInsets = insets;
[aButton addTarget:self action:@selector(back) forControlEvents:UIControlEventTouchUpInside];
}
我将“[UIImage imageNamed:]”更改为“[UIImage imageWithContentsOfFile:]”,一切正常。为什么 '[UIImage imageNamed:]' 会导致这个错误?
【问题讨论】:
-
如果您收到此错误,则您的应用程序将编译。您的图像是否在要复制的文件列表中?
-
是的,我在 iPhone 上安装 32 位或 64 位都没有问题。
-
你应该更新标题
-
@Suprie 请在
[UIImage imageNamed]附近发布一些代码。 -
@AlexanderPerechnev 似乎每个“[UIImage imageNamed]”都在崩溃。如果我将其更改为 '[UIImage imageWithContentsOfFile]' 它会正常运行。
标签: ios objective-c iphone ipad