1

今天我的应用程序崩溃了,我知道为什么。我有一个 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

这些是我的滚动视图配置(没有 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

4

1 回答 1

1

解决了。

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

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

亲切的问候。鲨鱼

于 2011-11-29T13:16:51.273 回答