目标C:UILongPressGestureRecognizer错误

时间:2012-01-20 06:13:38

标签: objective-c ios uiscrollview uigesturerecognizer

我也尝试在我的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"
    }
}

1 个答案:

答案 0 :(得分:0)

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

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

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