【发布时间】:2015-07-29 18:54:19
【问题描述】:
我正在尝试在 iOS 中使用 DollarPGestureRecognizer 到 webView。我已经按照程序以编程方式和使用情节提要在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
我没有得到真正的问题。
【问题讨论】:
-
在谷歌上搜索了很多之后,我知道要在 UIWebView 中激活触摸事件,下面的教程似乎很有趣wyldco.com/blog/2010/11/how-to-capture-touches-over-a-uiwebview
标签: ios objective-c webview gesture