【问题标题】:App crash on iOS7 but runs fine with iOS6应用程序在 iOS 7 上崩溃,但在 iOS 6 上运行良好
【发布时间】:2013-10-18 07:38:42
【问题描述】:

在对仅在 iOS7 上发生的崩溃进行故障排除时(iOS6 很好),该应用程序在对故障排除没有帮助的行上崩溃了几次,但最终在像 [object release] 这样的行上崩溃了一次。

删除违规行后,崩溃消失了。

旧代码:

[imageView removeFromSuperview];
[imageView release];
imageView = nil;
imageView = [[UIImageView alloc] initWithImage:image];
[self addSubview:imageView];

新代码:

[imageView removeFromSuperview];
//[imageView release];
imageView = nil;
imageView = [[UIImageView alloc] initWithImage:image];
[self addSubview:imageView];

堆栈在这里显示崩溃:objc_msgSend ()

如果有人能用旧代码解释为什么它在 iOS7 上崩溃以及我做错了什么,我将不胜感激? 另外我想了解为什么它没有在 iOS6 上崩溃。

【问题讨论】:

    标签: crash ios7


    【解决方案1】:

    尝试启用 NS Zombies 以检查您是否没有像听起来那样过度释放它。您应该在释放它之前检查 imageView 是否不是 nil :)

    如果可以的话,我建议您搬到 ARC。

    【讨论】:

    • 感谢您的意见。启用 ARC 解决了我的问题。
    最近更新 更多