zoom bouncing +导航栏后退按钮click = app crash

时间:2011-11-08 16:01:02

标签: ios xcode uiscrollview zoom backbarbuttonitem

今天我崩溃了我的应用程序,我知道为什么。 我有一个带有ScrollView和ImageView的UIViewController(类图片)。

@property (nonatomic, retain) IBOutlet UIScrollView *scrollview;
@property (nonatomic, retain) IBOutlet UIImageView *imageview;
@property (nonatomic, retain) IBOutlet UIActivityIndicatorView *activityIndicator;  

这是我通过pushViewController:pic animated:YES

调用的第三个视图

这些是我的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。 如果我现在再次放大,按住拖动,用第三根手指按导航控制器栏的后退按钮,应用程序崩溃:

2011-11-08 16:48:45.572 Archiv[1319:707] *** -[Picture respondsToSelector:]: message sent to deallocated instance 0x44e3960
你能帮帮我吗?请不要告诉我关闭bounceZoom。 $ H @ RKY

1 个答案:

答案 0 :(得分:1)

解决。

问题是scrollview-delegate会触发事件反弹但该对象已经释放。删除代表,一切都很好。

- (void)viewWillDisappear:(BOOL)animated{    
    [scrollview setDelegate:nil];
}

亲切的问候。 SHARKY