I am developing in Objective-C , and I want to show the image via http url
in AlertView
?
I already get the image url like:http://192.72.1.1/DCIM/100__DSC/SNAP0053.JPG
, and convert the NSURL
to NSString
. But I can not show the image in AlertView , it is empty.
The code for convert the url to NSString and show in AlertView is like the following:
NSString *path = [url absoluteString];
NSData * imageData = [[NSData alloc] initWithContentsOfURL: [NSURL URLWithString: path]];
UIImage *Image=[UIImage imageWithData:imageData];
UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"Image" message:nil delegate:nil cancelButtonTitle:@"OK" otherButtonTitles:nil];
UIImageView *imageView = [[UIImageView alloc] init];
[imageView setImage:Image];
[alert addSubview:imageView];
[alert show];
But the AlertView did not show any image like the following picture.
Did I missing something ?
How to show the image via http url in AlertView in Objective-C ?