EXC_Breakpoint 滚动视图崩溃 [英] Crash on EXC_Breakpoint Scroll View
问题描述
自从我为 iOS 7 更新我的应用程序以来,这是一个新问题.每次我在我的设备或模拟器上启动应用程序时,我都会收到此错误代码
This is a new problem I have been having ever since I've been updating my app for iOS 7. Everytime I launch the app on my device or simulator, I get this error code
RecipeDetailViewController scrollViewDidScroll:]: 消息发送到释放实例 0x15746c40 并且它崩溃了.
RecipeDetailViewController scrollViewDidScroll:]: message sent to deallocated instance 0x15746c40 and it crashed.
我启用了 NSZombie,这就是它给我的代码.在它给出 exc_bad_access 代码之前.
I enabled NSZombie and that was the code it gave me. Before it was giving a exc_bad_access code.
这是我的 ScrollViewDidSCroll 代码
This is my code for ScrollViewDidSCroll
- (void)scrollViewDidScroll:(UIScrollView *)scrollView{
// Depending on how far the user scrolled, set the new offset.
// Divide by a hundred so we have a sane value. You could adjust this
// for different effects.
// The larger you number divide by, the slower the shadow will change
float shadowOffset = (scrollView.contentOffset.y/1);
// Make sure that the offset doesn't exceed 3 or drop below 0.5
shadowOffset = MIN(MAX(shadowOffset, 0), 0.6);
//Ensure that the shadow radius is between 1 and 3
float shadowRadius = MIN(MAX(shadowOffset, 0), 0.6);
//apply the offset and radius
self.navigationController.navigationBar.layer.shadowOffset = CGSizeMake(0, shadowOffset);
self.navigationController.navigationBar.layer.shadowRadius = shadowRadius;
self.navigationController.navigationBar.layer.shadowColor = [UIColor blackColor].CGColor;
self.navigationController.navigationBar.layer.shadowOpacity = 0.2;
}
推荐答案
另一个(不优雅的,imo)解决方案是在 dealloc 时将表的委托设置为 nil:
Another (inelegant, imo) solution is to set your table's delegate to nil on dealloc:
- (void)dealloc {
[_tableView setDelegate:nil];
}
似乎是一个错误,但我不能保证.我仍在为此寻找合理的解释.
Seems to be a bug, but I can't guarantee. I am still looking for a reasonable explanation for that.
注意:这可能适用于任何 UIScrollView 子类,而不仅仅是 UITableView.
Note: that probably applies for any UIScrollView subclass, not only UITableView.
这篇关于EXC_Breakpoint 滚动视图崩溃的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!