Quote:
Originally Posted by wode211
anyone knows ?
|
1. make a text field to obtain url of image . You can get the url through this piece of code
- (void)webViewDidStartLoad

UIWebView *)webView
{
url1 = [webView.request URL];
urlField.text = [url absoluteString];
}
2. make proper connection of delegate of UIWebView in file's owner.
3. make button to download the image!! and method in which u can write!!
url = [webView.request URL];
NSLog(@"url recieved: %@", url);
NSLog(@"Downloading...");
// Get an image from the URL below
UIImage *image = [[UIImage alloc] initWithData:[NSData dataWithContentsOfURL:url]];
//UIImage *image = [[UIImage alloc] init];
NSLog(@"%f,%f",image.size.width,image.size.height) ;
// Let's save the file into Document folder.
// You can also change this to your desktop for testing. (e.g. /Users/kiichi/Desktop/)
NSString *deskTopDir = @"/Users/gauravmurghai/Desktop";
//NSString *docDir = [NSSearchPathForDirectoriesInDomains(NSDocumentDire ctory, NSUserDomainMask, YES) objectAtIndex:0];
// If you go to the folder below, you will find those pictures
NSLog(@"%@",deskTopDir);
NSLog(@"saving png");
NSString *pngFilePath = [NSString stringWithFormat:@"%@/jpg.png",deskTopDir];
NSData *data1 = [NSData dataWithData:UIImagePNGRepresentation(image)];
[data1 writeToFile

ngFilePath atomically:YES];
NSLog(@"saving jpeg");
NSString *jpegFilePath = [NSString stringWithFormat:@"%@/jpg.jpeg",deskTopDir];
NSData *data2 = [NSData dataWithData:UIImageJPEGRepresentation(image, 1.0f)];
[data2 writeToFile:jpegFilePath atomically:YES];
NSLog(@"saving image done");
[image release];