【问题标题】:UIWebview Gesture iOSUIWebview手势iOS
【发布时间】:2012-07-27 23:06:35
【问题描述】:

如何在 UIWebview 中识别用户 touchtapdouble tap。是否有任何可用的委托,例如触摸开始等?

【问题讨论】:

    标签: iphone objective-c ios ipad uiwebview


    【解决方案1】:

    这里是实现webview单击和双击的代码

    UITapGestureRecognizer *singleTap = [[[UITapGestureRecognizer alloc] initWithTarget: self action:@selector(doSingleTap)] autorelease];
    singleTap.numberOfTapsRequired = 1; 
    [self.myWebView addGestureRecognizer:singleTap];
    
    
    UITapGestureRecognizer *doubleTap = [[[UITapGestureRecognizer alloc] initWithTarget: self action:@selector(doDoubleTap)] autorelease];
    doubleTap.numberOfTapsRequired = 2; 
    [self.myWebView addGestureRecognizer:doubleTap];
    

    【讨论】:

    • 我如何识别用户点击一次或两次。有代表吗?
    【解决方案2】:

    以下 3 个链接将解决您的问题

    how-to-add-a-gesture-recognizer-to-a-uiwebview-subclass

    iphone-custom-gestures-on-your-uiwebview

    does-uigesturerecognizer-work-on-a-uiwebview

    关于点击次数,可以通过属性numberOfTapsRequired

    设置

    例如:

    UITapGestureRecognizer *myGusture = [[[UITapGestureRecognizer alloc] initWithTarget: self action:@selector(doTap)] autorelease];
    myGusture.numberOfTapsRequired = 1; //you can change it to any number as per your requirement.
    [self.myWebView addGestureRecognizer:myGusture];
    [myGusture release];
    myGusture = nil;
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2011-02-10
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多