目标C:UILongPressGestureRecognizer错误

我正在尝试把我的scrollView UILongPressGestureRecognizer,但它不工作。

长时间触摸后出现错误:“线程1:程序接收信号SIGABRT”

在这里我的代码:

- (void)viewDidLoad { [super viewDidLoad]; longPressToDrag = [[UILongPressGestureRecognizer alloc] initWithTarget:scrollView action:@selector(forLongPress:)]; longPressToDrag.minimumPressDuration = 3.0; [scrollView addGestureRecognizer:longPressToDrag]; [self pages]; } - (void)forLongPress:(UILongPressGestureRecognizer *)gestureRecognizer { NSLog(@"Long Touch"); } 

我在这里有错误:

 int main(int argc, char *argv[]) { @autoreleasepool { return UIApplicationMain(argc, argv, nil, NSStringFromClass([AppDelegate class])); //<--- Thread 1: Program received signal "SIGABRT" } } 

我认为你使用了错误的目标。 尝试改变

 longPressToDrag = [[UILongPressGestureRecognizer alloc] initWithTarget:scrollView action:@selector(forLongPress:)]; 

 longPressToDrag = [[UILongPressGestureRecognizer alloc] initWithTarget:self action:@selector(forLongPress:)];