0

this is a case in which the photo is taken using camera and saved in library. and the photo is opened in webpage for editing purpose and how to save back to device memory with another name? ie... Hw to save the photo displayed in webview to photo library? Thanks in adv.

Gobi M
  • 3,243
  • 5
  • 32
  • 47
  • Yes i have did what you have said, my ques is after that i have modified this photo in webview then how to save back to document directory or photo library with same or diff name – Gobi M Jul 25 '13 at 10:29
  • check the answer might be this is fix your problem. – Nitin Gohel Jul 25 '13 at 10:47

2 Answers2

3

bellow method done your need:-

 - (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;
}

Download the demo:

http://dl.dropbox.com/u/51367042/ImageFromWebView.zip and cradit gose to this

Screenshot

enter image description here

Community
  • 1
  • 1
Nitin Gohel
  • 49,482
  • 17
  • 105
  • 144
  • Thanks Its working...NSString *imgURL = [NSString stringWithFormat:@"document.elementFromPoint(%f, %f).src", touchPoint.x, touchPoint.y]; NSString *urlToSave = [webV stringByEvaluatingJavaScriptFromString:imgURL]; Here it uses the gesture right? It would be better if we get the imgURL by the image tag id.. – Gobi M Jul 25 '13 at 11:17
0

read the tutorial from here. It will solve your problem

Manish Agrawal
  • 10,958
  • 6
  • 44
  • 76