gpt4 book ai didi

ios - iPhone 应用程序无法在 iPad 上运行

转载 作者:行者123 更新时间:2023-11-29 02:18:29 25 4
gpt4 key购买 nike

我在将仅适用于 iPhone 的应用程序运行到 iPad 时遇到了问题。崩溃日志的错误是

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:]”会导致此错误?

最佳答案

问题是您使用无效参数将消息发送到 UIImage (调用静态函数)。当然。

这就是为什么您在 -[__NSCFString mutableCopyWithZone:] 上遇到错误,因为 [UIImage imageNamed:] 需要 NSString 参数,但得到有问题。

所以请发布您的代码。

更新

既然你说过你只为 iPhone 编译了应用程序并在 iPad 上运行它,我认为问题出在 iPad 上的图像查找上。不幸的是我不能更深入,但根据这个文档https://developer.apple.com/library/mac/documentation/Cocoa/Conceptual/LoadingResources/ImageSoundResources/ImageSoundResources.html我们知道 iPad 首先查找 iPad 特定的资源。所以我不确定,但似乎 [UIImage imageNamed:] 此时某个地方令人困惑。您可以尝试将 actionbar_back_nor.pngactionbar_back_pre.png 复制到 actionbar_back_nor~ipad.pngactionbar_back_pre~ipad.png.

我不确定,但这似乎是唯一可以隐藏原因的点。

但是问题很有趣,几天后我会自己研究一下。因此,如果您需要更多信息,我们可以与您联系。

关于ios - iPhone 应用程序无法在 iPad 上运行,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28451272/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com