I have a UIWebView in which it has a UITapGestureRecognizer and basically in my tap gesture recognizer I have:
- (CGPoint) pointsForImage:(UIGestureRecognizer *)sender
{
CGPoint pt = [sender locationInView:self];
NSString * offsetTop = [NSString stringWithFormat:@"document.elementFromPoint(%f, %f).offsetTop", pt.x, pt.y
];
NSString * offsetLeft = [NSString stringWithFormat:@"document.elementFromPoint(%f, %f).offsetLeft", pt.x, pt.y
];
NSString * scrollTop = [NSString stringWithFormat:@"document.elementFromPoint(%f, %f).parentNode.scrollTop", pt.x, pt.y
];
NSString * scrollLeft = [NSString stringWithFormat:@"document.elementFromPoint(%f, %f).parentNode.scrollLeft", pt.x, pt.y
];
float x = [[self stringByEvaluatingJavaScriptFromString:offsetTop] floatValue] - [[self stringByEvaluatingJavaScriptFromString:scrollTop] floatValue];
float y = [[self stringByEvaluatingJavaScriptFromString:offsetLeft] floatValue] - [[self stringByEvaluatingJavaScriptFromString:scrollLeft] floatValue];
CGPoint point = CGPointMake(x, y);
return point;
}
基本上,我正试图做的是找到图像的顶端左侧X和头寸。 并非与IDWebView有关,而是与内容观点有关。 因此,我说,图像的位置是1 000个缩影子,但我现在将“IDWeb”电文减半,因此我想看到的数字是200个。 我希望,这是有意义的。