这是使用相机拍摄照片并保存在库中的情况。 并且在网页中打开照片以进行编辑以及如何使用其他名称保存回设备内存?即......如何将webview中显示的照片保存到照片库? 谢谢你。
答案 0 :(得分:3)
波纹管方法完成了您的需求: -
- (void)viewDidLoad
{
[super viewDidLoad];
// Do any additional setup after loading the view, typically from a nib.
NSURL *url = [NSURL URLWithString:@"yourimageurl"];
NSURLRequest *req = [NSURLRequest requestWithURL:url];
[webV loadRequest:req];
UITapGestureRecognizer *gs = [[UITapGestureRecognizer alloc] init];
gs.numberOfTapsRequired = 1;
gs.delegate = self;
[self.view addGestureRecognizer:gs];
}
-(BOOL)gestureRecognizer:(UIGestureRecognizer *)gestureRecognizer shouldReceiveTouch:(UITouch *)touch {
NSLog(@"TAPPED");
//Touch gestures below top bar should not make the page turn.
//EDITED Check for only Tap here instead.
if ([gestureRecognizer isKindOfClass:[UITapGestureRecognizer class]]) {
CGPoint touchPoint = [touch locationInView:self.view];
NSUserDefaults * userDefaults = [NSUserDefaults standardUserDefaults];
bool pageFlag = [userDefaults boolForKey:@"pageDirectionRTLFlag"];
NSLog(@"pageFlag tapbtnRight %d", pageFlag);
if(self.interfaceOrientation==UIInterfaceOrientationPortrait||self.interfaceOrientation==UIInterfaceOrientationPortraitUpsideDown) {
NSString *imgURL = [NSString stringWithFormat:@"document.elementFromPoint(%f, %f).src", touchPoint.x, touchPoint.y];
NSString *urlToSave = [webV stringByEvaluatingJavaScriptFromString:imgURL];
NSLog(@"urlToSave :%@",urlToSave);
NSURL * imageURL = [NSURL URLWithString:urlToSave];
NSData * imageData = [NSData dataWithContentsOfURL:imageURL];
UIImage * image = [UIImage imageWithData:imageData];
imgView.image = image;
}
}
return YES;
}
下载演示
http://dl.dropbox.com/u/51367042/ImageFromWebView.zip和cradit gose到this
<强>截图强>
答案 1 :(得分:0)
从here阅读教程。它将解决您的问题