2010-03-21 103 views
1

我想在UIWebView中捕捉雙擊事件。我從UIWebController派生了一個類。當我雙擊它的接縫時,UIWebController自己正在響應我的雙擊而不是我的班級。奇怪的是,當我將繼承從UIView繼承時,一切正常。Iphone:UIWebview和雙擊水龍頭

下面是我的代碼片段,它應該在雙擊時調用彈出窗口。

在初始化函數:

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

也:

- (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]; 
} 
+0

UITapGestureRecognizer在NDA下。 – indragie 2010-03-21 15:39:08

+0

@Macatomy:這是否也適用於使用情況? – Gumbo 2010-03-21 16:28:29

+0

你可以在你的項目中使用它,只是你不允許公開討論它。 – indragie 2010-03-21 17:01:45

回答

0

我不能UITapGestureRecognizer的行爲說話。我知道如果你重寫UIWebView的觸摸事件方法,你可以得到非常精細的控制。

查看「回覆事件」here