如何阅读这个崩溃日志?
对于任何试图阅读这个问题的人来说,我和乔纳斯之间进行了广泛的讨论,并且问题在讨论过程中发生了多次变化,因此重述我们在这里经历的一切是没有用的。如果您在阅读崩溃日志时遇到问题,请参阅 stackoverflow 上的此问题!感谢您的理解。
Jonas:这是我在上一篇评论中提到的代码片段:
if ([performance.favorites integerValue] == 1) {
UIImage *starImage = [UIImage imageWithContentsOfFile:[[NSBundle mainBundle] pathForResource:@"fav-star" ofType:@"png"]];
cell.favoritesImage.image = starImage;
}
else
{
cell.favoritesImage.image = nil;
}
因此,如果执行了 else
块,那么如果 TableViewCell 会导致 [favoritesImage release]
调用崩溃没有显示收藏夹图像正在被释放?
所以我可以简单地添加一个将 alpha 设置为 0 的随机图像,而不是将其设置为 nil,以达到相同的效果,但不会有任何内存泄漏?
For anyone who's trying to read this question, there have been extensive discussions between me and Jonas and the question changed over the course of the discussion several times so there would be no use in restating everything we went through here. If you have problems reading a crash log please refer to this question on stackoverflow! Thank you for your understanding.
Jonas: Here's the code snippet I was referring to in my last comment:
if ([performance.favorites integerValue] == 1) {
UIImage *starImage = [UIImage imageWithContentsOfFile:[[NSBundle mainBundle] pathForResource:@"fav-star" ofType:@"png"]];
cell.favoritesImage.image = starImage;
}
else
{
cell.favoritesImage.image = nil;
}
So if the else
block is executed, would that make the [favoritesImage release]
call crash if a TableViewCell that is not showing the favorites Image is being deallocated?
So I could simply instead of putting it to nil add a random image with alpha set to 0 to have the same effect but not have any memory leaks?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
“阅读”崩溃报告并不总是那么容易。
您发送的两个没有显示任何“自己编码”的方法。
而且你有“EXC_BAD_ACCESS”,所以我几乎会说:“这是一个内存释放/保留问题”:
您可能会提前发布 UITableView 的某些内容。
您是否检查过 UITableViewCell 是否正确自动释放?
UITableViewCell 中的所有子视图和对象是否都自动释放或至少不释放为 0?
更多细节:
1)我永远不会通过 NIB/XIB 创建 UITableViewCell 子类。你会损失很多性能。我建议您通过编码创建 UITableViewCell 子类。
请记住:XIB (xml) 的压缩需要时间,当您滚动 UITableView 时,可能会出现丑陋的情况。
2)对于您遇到的内存问题:检查以下内容:How do你从 Xib 文件加载自定义 UITableViewCells? autorelease 在那里不是正确的事情。
It's not always easy to "read" crash reports.
The two you sent does not show up any "own coded" methods.
And you have "EXC_BAD_ACCESS", so i would pretty much say: "it's a memory release/retain issue":
You might release something of the UITableView to early.
Did you check that the UITableViewCell is proper autoreleased?
Are all subviews and objects within the UITableViewCell on autorelease or at least not released to 0?
More details:
1) i would never create a UITableViewCell subclass by NIB/XIB. You loose a lot of performance. I recommend you to create the UITableViewCell subclass by coding.
Remember: the deflating of XIB (xml) needs time and when you scroll through a UITableView there might ugly buckings.
2) for the memory issue you have: check this: How do you load custom UITableViewCells from Xib files? autorelease is not the right thing there.