0

次のコードは、iOS5およびiOS5.1では機能しません(ただし、iOS 6では機能します)。

- (void)viewDidLoad {
    ...
    UILongPressGestureRecognizer* gesture = [[[UILongPressGestureRecognizer alloc] initWithTarget:self action:@selector(handleLongPress:)] autorelease];
    [myWebView addGestureRecognizer:gesture];
}

- (void)handleLongPress:(UIGestureRecognizer*)gestureRecognizer {
  ...
}

問題を解決する方法は?助けてくれてありがとう!

4

2 に答える 2

1

正しいコード:

- (void)viewDidLoad {
    UILongPressGestureRecognizer* gesture = [[[UILongPressGestureRecognizer alloc] initWithTarget:self action:@selector(handleLongPress:)] autorelease];
    gesture.delegate = self;
    [myWebView addGestureRecognizer:gesture];
}

- (BOOL)gestureRecognizer:(UIGestureRecognizer *)gestureRecognizer shouldRecognizeSimultaneouslyWithGestureRecognizer:(UIGestureRecognizer *)otherGestureRecognizer {
    return YES;
}
于 2012-11-09T03:01:10.873 に答える
0

このコードを試してください。

    UILongPressGestureRecognizer *longpressGesture = [[UILongPressGestureRecognizer alloc] initWithTarget:self action:@selector(longPressHandler:)];
    longpressGesture.minimumPressDuration = 5;
    [longpressGesture setDelegate:self];
    [myWebView addGestureRecognizer:longpressGesture];
    [longpressGesture release];

    - (void)longPressHandler:(UILongPressGestureRecognizer *)gestureRecognizer {
        NSLog(@"longPressHandler");
    }
于 2012-11-09T04:01:10.480 に答える