开发者

Iphone: UIWebview and double taps

I would like to trap a double tap event in a UIWebView. I have derived a class from UIWebController. When I double tap it seams that the UIWebController itself is responding to my double taps instead of my class. The weird thing is that when I change the inheritance to inherit from UIView everything works just fine.

Below are snippets f开发者_如何学Gorom my code which is supposed to invoke a pop-up when double tapped.

In the init function:

//Setup action for double tap
    UITapGestureRecognizer *tap = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(handleDoubleTap:)];
    tap.numberOfTapsRequired = 2;
    [super addGestureRecognizer:tap];
    [tap release];

And Also:

- (void)handleDoubleTap:(UIGestureRecognizer *)gestureRecognizer 
{
    UIAlertView *someError = [[UIAlertView alloc] initWithTitle: @"Network error" message: @"Hello" delegate: self cancelButtonTitle: @"Ok" otherButtonTitles: nil];
    [someError show];
    [someError release];


    //[[NSNotificationCenter defaultCenter] postNotificationName:NOTIFICATION_FLIP_TO_PAGE_VIEW object:nil];  
}


I can't speak to the behavior of UITapGestureRecognizer. I do know that you can get very granular control if you override the touch event methods of the UIWebView.

Check out "Responding to Events" here.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜