iOS:UILongPressGestureRecognizer EXC_BAD_ACCESS
我在 viewDidLoad 中有这段代码:
UILongPressGestureRecognizer *change = [[UILongPressGestureRecognizer alloc] initWithTarget:self action:@selector(dragGestureChange:)];
[imageView addGestureRecognizer:change];
for (UILongPressGestureRecognizer *gestureRecognizer in imageView.gestureRecognizers)
{
[gestureRecognizer requireGestureRecognizerToFail:change];
}
当我调用这个代码在哪里的类时,第一次一切正常,但第二次它崩溃,因为 EXC_BAD_ACCESS;如果我使用scrollView而不是imageView,就不会发生这种情况,为什么???
I have this code in viewDidLoad:
UILongPressGestureRecognizer *change = [[UILongPressGestureRecognizer alloc] initWithTarget:self action:@selector(dragGestureChange:)];
[imageView addGestureRecognizer:change];
for (UILongPressGestureRecognizer *gestureRecognizer in imageView.gestureRecognizers)
{
[gestureRecognizer requireGestureRecognizerToFail:change];
}
when I call the class where is this code, the first time it's all ok , but the second time it crash because EXC_BAD_ACCESS; it don't happens if instead of an imageView I use a scrollView, why???
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
使用此代码,您需要所有识别器(包括更改)失败才能更改成功,这不太好,
您应该将其更改为此
并且您应该在此处发布更改。不知道这是否能真正解决您的问题,在您发布的内容中看不到任何其他错误。
With this code, you are requiring all recognizers (including change) to fail for change to succeed, which cannot be good
you should change it to this
And you should release change here. Don't know if that will actually solve your problem, can't see anything else wrong in what you posted.
也许可以尝试这个:UIButtonLongTab。使用背景图像作为您的图像。我在 ScrollView 内的应用程序中使用它,它工作没有问题。
Maybe try this: UIButtonLongTab. Use the Background-Image for your Images. I use this in an App within a ScrollView and it works without problem.