【问题标题】:Using DollarPGestureRecognizer in webView iOS在 webView iOS 中使用 DollarPGestureRecognizer
【发布时间】:2015-07-29 18:54:19
【问题描述】:

我正在尝试在 iOS 中使用 DollarPGestureRecognizerwebView。我已经按照程序以编程方式和使用情节提要在webView 上识别它,但它在GestureView.h 文件的drawRect 方法上抛出异常

- (void)drawRect:(CGRect)rect {
    CGContextRef context = UIGraphicsGetCurrentContext();
    CGContextSetLineWidth(context, 5.0);
    CGContextSetLineCap(context, kCGLineCapRound);
    NSLog(@"I'm just here, got me!!");

    for (int i = 0; i < [completeStrokes count]; i++) {
        Stroke *stroke = [completeStrokes objectAtIndex:i];
        NSLog(@"Welcome to the freakshow");
        [self drawStroke:stroke inContext:context];
    }

    for (NSValue *touchValue in currentTouches) {
        Stroke *stroke = [currentTouches objectForKey:touchValue];
        [self drawStroke:stroke inContext:context];
    }
}

它没有进入第一个循环并抛出

Thread1_EXC_BAD_ACCESS(代码 1)。

为了在webView 上启用手势,我还实现了UIWebViewDelegate 方法

- (BOOL)gestureRecognizer:(UIGestureRecognizer *)gestureRecognizer shouldReceiveTouch:(UITouch *)touch
- (BOOL)gestureRecognizer:(UIGestureRecognizer *)gestureRecognizer shouldRecognizeSimultaneouslyWithGestureRecognizer:(UIGestureRecognizer *)otherGestureRecognizer

我没有得到真正的问题。

【问题讨论】:

标签: ios objective-c webview gesture


【解决方案1】:

由于这里的 webview 正在加载一个 html 页面,所以用于 ObjectiveC 的 DollarPGestureRecognizer 库将无法工作。识别器本身有 javascript 库来处理 html。 https://depts.washington.edu/aimgroup/proj/dollar/pdollar.js

我没有实现 javascript 库。爱好者应该去。而且这个 ObjectiveC 的识别器不支持 iOS 中的 webview 和 imageview。

【讨论】:

  • 虽然理论上这可以回答这个问题,it would be preferable 在这里包含答案的基本部分,并提供链接以供参考。
猜你喜欢
  • 1970-01-01
  • 2015-07-18
  • 1970-01-01
  • 1970-01-01
  • 2011-05-07
  • 2011-05-13
  • 1970-01-01
  • 2015-12-11
  • 1970-01-01
相关资源
最近更新 更多