本文介绍了尝试调用[UITableView panGestureRecognizer]时获取EXC_BAD_ACCESS的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

刚刚将xCode升级到4.5。 iOS 5仍然是我的部署目标,但Base SDK现在是6.0。

Just upgraded xCode to 4.5. iOS 5 is still my deployment target, but Base SDK is now 6.0.

应用程序现在崩溃,而以前没有。该项目使用ARC。

Application now crashes where previously it did not. The project uses ARC.

违规行是UITableView上的属性调用...要求panGestureRecognizer(下面第3行)。

The offending line is a property call on a UITableView... asking for the panGestureRecognizer (line 3 below).

-(void)viewWillAppear:(BOOL)animated {
        [super viewWillAppear:animated];
        UIPanGestureRecognizer* pgr = [imageTableView panGestureRecognizer];
        [pgr setMinimumNumberOfTouches:2];
        [pgr setMaximumNumberOfTouches:2];
}

产生以下错误消息:

- [UIScrollViewPanGestureRecognizer retain]:发送到解除分配的实例0x1ea38f70的消息

这怎么可能? Zombie Analysis说,gestureRecognizer已经发布了吗?!

How is this possible? Zombie Analysis says that the gestureRecognizer has been released already?!

推荐答案

原来这是一个ARC问题......两种不同的解决方案对于那些感兴趣的人。

Turns out this was an ARC issue... two different solutions for those interested.

@autoreleasepool {
    UIPanGestureRecognizer* pgr = [imageTableView panGestureRecognizer];
    [pgr setMinimumNumberOfTouches:2];
    [pgr setMaximumNumberOfTouches:2];
}

[imageTableView.panGestureRecognizer setMinimumNumberOfTouches:2];
[imageTableView.panGestureRecognizer setMaximumNumberOfTouches:2];

经验教训,如果不可能......尝试ARC作为罪魁祸首。

Lesson learned, if it can't be possible.... try ARC as the culprit.

这篇关于尝试调用[UITableView panGestureRecognizer]时获取EXC_BAD_ACCESS的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-21 18:18