今天我的应用程序崩溃了,我知道为什么了。 我有一个 UIViewController(图片类),上面有一个 ScrollView 和一个 ImageView。
@property (nonatomic, retain) IBOutlet UIScrollView *scrollview;
@property (nonatomic, retain) IBOutlet UIImageView *imageview;
@property (nonatomic, retain) IBOutlet UIActivityIndicatorView *activityIndicator;
这是我通过 pushViewController:pic animated:YES
调用的第三个 View
这些是我的 ScrollView 配置(没有 initWithFrame):
[scrollview setBackgroundColor:[UIColor blackColor]];
[scrollview setShowsVerticalScrollIndicator:NO];
[scrollview setShowsHorizontalScrollIndicator:NO];
[scrollview setContentSize:scrollview.frame.size];
[scrollview setAlwaysBounceVertical:YES];
[scrollview setAlwaysBounceHorizontal:YES];
#warning BouncesZoom + BackButton = App Crash!
scrollview.bouncesZoom = YES;
scrollview.decelerationRate = UIScrollViewDecelerationRateFast;
[scrollview setDelegate:self];
所以现在我放大,当我停止拖动图片时,图片会重新调整为 minimumSize。 如果我现在再次放大,按住拖动,用无名指按下导航 Controller 栏的后退按钮,应用程序会崩溃:
2011-11-08 16:48:45.572 Archiv[1319:707] *** -[Picture respondsToSelector:]: message sent to deallocated instance 0x44e3960
你能帮帮我吗?请不要告诉我关闭 bounceZoom。 $h@rky
最佳答案
已解决。
问题是 scrollview-delegate 触发事件反弹但对象已经释放。删除委托(delegate),一切都很好。
- (void)viewWillDisappear:(BOOL)animated{
[scrollview setDelegate:nil];
}
亲切的问候。鲨鱼
关于ios - 缩放弹跳 + 导航栏后退按钮点击 = 应用程序崩溃,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8053333/