我尝试了所有可能的搜索,但是在一个星期内我没有找到任何类似的东西。 我正在制作一个显示表格视图的应用程序。单元格(由自定义类和Interface Builder生成)可以使用单元类中的UIPanGestureRecognizer进行拖动。 一切正常,只是罚款时,我按住上的小区,其错误的应用程序崩溃的手指:即使没有实施,uilongpressgesturerecognizer也会崩溃
-[UILongPressGestureRecognizer translationInView:]: unrecognized selector sent to instance 0x94670a0
*** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[UILongPressGestureRecognizer translationInView:]: unrecognized selector sent to instance 0x94670a0'
我知道它的意思(通常发送到实例的错误参数),但我真不不知道这怎么可能,因为我的代码中没有UILongPressGestureRecognizer的踪迹。 我试图截取每个单元格分配之前的LongPressGestureREcognizer EVERYWHERE(在单元类中,在tableview的类中),但错误仍然是一样的(我在主题中查看了许多线程并相信我,语法是正确的。
如果你想要的任何其他文件随意问(这是我的第一篇文章在这里,我不知道到底是什么,我必须展示)。
谢谢你们的宝贵帮助。
好问题仍然存在抱歉打扰:(我设法设置一个断点和打印堆栈跟踪。这是它:
0 uBellow 0x0000ac57 -[OpinionCell gestureRecognizerShouldBegin:] + 71
1 UIKit 0x00914939 -[UIGestureRecognizer _shouldBegin] + 1334
2 UIKit 0x0091181a -[UIGestureRecognizer setState:] + 152
3 UIKit 0x00921cea -[UILongPressGestureRecognizer enoughTimeElapsed:] + 127
4 libobjc.A.dylib 0x017186b0 -[NSObject performSelector:withObject:] + 70
5 UIKit 0x00787954 -[UIDelayedAction timerFired:] + 83
6 Foundation 0x0114d2c0 __NSFireTimer + 97
7 CoreFoundation 0x01bce376 __CFRUNLOOP_IS_CALLING_OUT_TO_A_TIMER_CALLBACK_FUNCTION__ + 22
8 CoreFoundation 0x01bcde06 __CFRunLoopDoTimer + 534
9 CoreFoundation 0x01bb5a82 __CFRunLoopRun + 1810
10 CoreFoundation 0x01bb4f44 CFRunLoopRunSpecific + 276
11 CoreFoundation 0x01bb4e1b CFRunLoopRunInMode + 123
12 GraphicsServices 0x022337e3 GSEventRunModal + 88
13 GraphicsServices 0x02233668 GSEventRun + 104
14 UIKit 0x00648ffc UIApplicationMain + 1211
15 uBellow 0x0000287d main + 141
16 uBellow 0x000027a5 start + 53
上的代码的应用程序块: 我通过截获UILongPressGestureRecognizer解决
-(BOOL)gestureRecognizerShouldBegin:(UIPanGestureRecognizer *)gestureRecognizer {
CGPoint translation = [gestureRecognizer translationInView:[self superview]];
编辑,它是一种安全的方式?
-(BOOL)gestureRecognizerShouldBegin:(UIPanGestureRecognizer *)gestureRecognizer {
if([gestureRecognizer isKindOfClass:[UILongPressGestureRecognizer class]]){
return NO;
}else{
CGPoint translation = [gestureRecognizer translationInView:[self superview]];
// Check for horizontal gesture
if (fabsf(translation.x) > fabsf(translation.y)){
return YES;
}
}
return NO;}
显示在你的'xib'对象和任何相关的代码 – 2013-04-26 14:51:11
细胞物体的图像是以下内容:http:// postimg。org/image/jnird1ifh /代码的问题是我没有编写任何有关UILongpressGestureRecognizer的代码,所以没有什么不寻常的我可以看到 – dado728 2013-04-26 14:58:08
你的问题是使用自定义手势识别器,默认情况下已经集成到UITableView中:http:// developer.apple.com/library/ios/#documentation/uikit/reference/UITableViewDelegate_Protocol/Reference/Reference.html(阅读“重新排序表格行”部分 – 2013-04-26 15:08:18