[英]iPhone app won't run on iPad
I've encountered problem when running iPhone only apps to iPad. 在iPad上仅运行iPhone应用程序时遇到了问题。 The error from crash log is
崩溃日志中的错误是
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
In the XCode, the crashed cause by '[UIImage imageNamed]'. 在XCode中,崩溃原因是[UIImage imageNamed]。 Which confused me.
这让我感到困惑。 I wonder how to debug and fix this kind of error
我不知道如何调试和修复这种错误
UPDATE : 更新:
the breakpoint stop at this line of code 断点在此行代码处停止
- (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];
}
I changed the '[UIImage imageNamed:]' to '[UIImage imageWithContentsOfFile:]' and the things run normal. 我将“ [UIImage imageNamed:]”更改为“ [UIImage imageWithContentsOfFile:]”,一切正常。 Why the '[UIImage imageNamed:]' cause this error?
为什么'[UIImage imageNamed:]'导致此错误?
The problem is you send the message to UIImage
(call static function) with invalid parameter. 问题是您使用无效的参数将消息发送到
UIImage
(调用静态函数)。 For sure. 当然。
That's why you are getting error on -[__NSCFString mutableCopyWithZone:]
, because [UIImage imageNamed:]
expects NSString
parameter, but gets something wrong. 这就是为什么您在
-[__NSCFString mutableCopyWithZone:]
上出错的原因,因为[UIImage imageNamed:]
期望使用NSString
参数,但是出错了。
So please post your code. 因此,请发布您的代码。
Update 更新
Since you've said that you compiled your app for iPhone only and run it on iPad, I think the problem is in image lookup on iPad. 既然您说过只为iPhone编译了应用程序并在iPad上运行,我认为问题出在iPad上的图像查找中。 Unfortunately I can't go deeper, but according to this document https://developer.apple.com/library/mac/documentation/Cocoa/Conceptual/LoadingResources/ImageSoundResources/ImageSoundResources.html we know that iPad looks up for iPad-specific resources first.
不幸的是,我无法深入探讨,但是根据此文档https://developer.apple.com/library/mac/documentation/Cocoa/Conceptual/LoadingResources/ImageSoundResources/ImageSoundResources.html,我们知道iPad查找针对iPad的产品资源第一。 So I'm not sure, but it seems like
[UIImage imageNamed:]
confuses somewhere at this point. 所以我不确定,但是此时
[UIImage imageNamed:]
似乎有些混乱。 You can try to copy your actionbar_back_nor.png
and actionbar_back_pre.png
to actionbar_back_nor~ipad.png
and actionbar_back_pre~ipad.png
. 您可以尝试将
actionbar_back_nor.png
和actionbar_back_pre.png
复制到actionbar_back_nor~ipad.png
和actionbar_back_pre~ipad.png
。
I am not sure, but this seems like the only point where reason can be hidden. 我不确定,但这似乎是唯一可以隐藏原因的地方。
But problem is very interesting and I'll research it for myself in a few days. 但是问题是非常有趣的,我将在几天之内自行研究。 So if you will need more information, we can be in touch.
因此,如果您需要更多信息,请与我们联系。
只需添加异常断点,它将确切显示代码崩溃的位置,然后使用强大的调试器。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.