在对仅在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上崩溃。
最佳答案
尝试启用NS Zombies来检查您是否没有尝试过听起来像是的过度释放它。您应该在释放它之前检查imageView是否为nil :)
如果可以的话,我建议您迁移到ARC。
关于crash - 应用程序在iOS 7上崩溃,但在iOS 6上运行良好,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19438743/