Image is not adding to the imageview in Iphone sdk
I'm doing an application using NSXmlParser. I'm getting data from server.I have to display details of the item including item image also.
I'm getting image data from parser, which is not adding to imageView .I'm using code as
UIImageView *warrantyCardImage;
warantyCardImage.image=[UIImage imageWithData:[NSData dataWithContentsOfURL:[NSURL URLWithString:warObj1.warrantyCardImagePath]]];
When I'm printing in console I'm getting value .By giving code as printf("\n%s:",[warObj1.warrantyCardImagePath UTF8String]) and getting output as http://123.237.186.221:8080/Warrantify/Barcode/barcodefbbab1开发者_开发问答dd-9ff0-448b-8d46-dcebf5d11b37.png
If I'm giving code as
UIImageView *warrantyCardImage;
warantyCardImage.image=[UIImage imageWithData:[NSData dataWithContentsOfURL:[NSURL URLWithString:@"http://123.237.186.221:8080/Warrantify/Barcode/barcodefbbab1dd-9ff0-448b-8d46-dcebf5d11b37.png"]]];
it is working ,the image is adding to imageView
Guy's hope that I will get a quick response from your side.
Thanks to all, Sri Lakshmi.
Verify that your data object is really being formed correctly. You are assuming it is in your sample.
UIImageView *warrantyCardImage;
NSData *imageData = [NSData dataWithContentsOfURL:[NSURL URLWithString:@"http://123.237.186.221:8080/Warrantify/Barcode/barcodefbbab1dd-9ff0-448b-8d46-dcebf5d11b37.png"]];
if(imageData)
{
warantyCardImage.image=[UIImage imageWithData:imageData];
}
else
{
NSLog(@"sadness");
}
You are using a synchronous download method which maybe isnt the best. Explore the docs around NSURLDownload http://developer.apple.com/library/mac/#documentation/Cocoa/Conceptual/URLLoadingSystem/Tasks/UsingNSURLDownload.html which might serve you better.
精彩评论