iphone - save photo in webview to ios photo library -
this case in photo taken using camera , saved in library. , photo opened in webpage editing purpose , how save device memory name? ie... hw save photo displayed in webview photo library? in adv.
bellow method done need:-
- (void)viewdidload { [super viewdidload]; // additional setup after loading view, typically 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 page turn. //edited check 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 demo:
http://dl.dropbox.com/u/51367042/imagefromwebview.zip , cradit gose this
screenshot
Comments
Post a Comment