I have a string variable tmpImgURLStr which contains URL like www.abc.com/img.png. i want to display that image in my imageView for that i have use some code but it’s not working which is given below:
NSLog(@"Img URL === %@",tmpImgURLStr);
NSData *mydata = [[NSData alloc] initWithContentsOfURL:[NSURL URLWithString:[NSString stringWithFormat:@"%@",tmpImgURLStr]]];
UIImage *myimage = [[UIImage alloc] initWithData:mydata];
[logoImg setImage:myimage];
As far as I can tell from your url – you have pdf, not an image. Usually
WebViews are used for displaying this sort of data.Update
Your
NSDatainitiation is kinda too long. You can actually initiate a URL without supplying formatted string:Also I’ve noticed that your URL is without protocol. You may want to try adding
http://orhttps://to it and then see what happens. And just in case check if yourlogoImgis actually wired to theNSImageViewin your NIB.