详解使用UIWebView获取所点位置图片URL教程
UIWebView获取所点位置图片URL教程是本文要介绍的内容,UIWebView有自己的UIResgure,如果我们手动加入自己的GestureRecognize将不能识别,如UILongPressGestureRecongnizer. 在浏览网页的时候,如果看到喜欢的图片,想把它保存下来如何办呢? 我们可以自己写一个程序来实现,用uiwebview开发一个自己的浏览器。关于说到uiwebview不能识别long press gesture,幸好有一个可以识别,那就是double click.因此我们注册它,代码如下:
[*]UITapGestureRecognizer *doubleTap = [ initWithTarget:self action:@selector(doubleTap:)];
[*]doubleTap.numberOfTouchesRequired = 2;
[*];
[*] UITapGestureRecognizer *doubleTap = [ initWithTarget:self action:@selector(doubleTap:)];
[*] doubleTap.numberOfTouchesRequired = 2;
[*] ;
然后就是实现doubleTap:
[*]-(void) doubleTap :(UITapGestureRecognizer*) sender
[*]{
[*]//<Find HTML tag which was clicked by user>
[*]//<If tag is IMG, then get image URL and start saving>
[*] int scrollPositionY = [ intValue];
[*] int scrollPositionX = [ intValue];
[*]
[*] int displayWidth = [ intValue];
[*] CGFloat scale = theWebView.frame.size.width / displayWidth;
[*]
[*] CGPoint pt = ;
[*] pt.x *= scale;
[*] pt.y *= scale;
[*] pt.x += scrollPositionX;
[*] pt.y += scrollPositionY;
[*]
[*] NSString *js = ;
[*] NSString * tagName = ;
[*] if () {
[*] NSString *imgURL = ;
[*] NSString *urlToSave = ;
[*] NSLog(@&quot;image url=%@&quot;, urlToSave);
[*] }
[*]}
小结:详解使用UIWebView获取所点位置图片URL教程的内容介绍完了,希望本文对你有所帮助!
【编辑推荐】
[*]iPhone开发 从UIWebView中获取Status Code实例教程
[*]iPhone应用程序 将图片保存到相册实例
[*]iPhone模拟器之将图片添加到相册实例
[*]详解iOS开发之UIWebView
[*]详解UIWebView之网络状况显示
页:
[1]