0
NSString *imgvalue=[[NSString alloc]initWithString:item.imgItem];
printf("\n img1 value is %s",[imgvalue UTF8String]);

cell.imageView.image=[UIImage imageNamed:@"unknown.jpg"];
if (imgvalue !=nil) 
{
    NSData *imageData;
    @try 
    {
        printf("\n image value in image data is %s",[imgvalue UTF8String]);
        imageData = [[NSData alloc]initWithContentsOfURL:[NSURL URLWithString:imgvalue]];
        printf("\n imageData Length is %d",[imageData length]);
    }
    @catch (NSException * e) 
    {
        //printf("Exception message is %s",[e);
    }
    @finally 
    {
        UIImage * imageFromImageData = [[UIImage alloc] initWithData:imageData];
        //[image setImage:imageFromImageData];
        cell.imageView.image=imageFromImageData;
        [imageData release];
        [imageFromImageData release];
    }   
}

获得 imgValue 后,我复制了该 url,当我在浏览器中签入时,它向我显示了图像,但它没有存储到 NSData。请帮助我

4

2 回答 2

0

更改此行

NSString *imgvalue=[[NSString alloc]initWithString:item.imgItem];

NSString *imgvalue=@"http://animals.catchsmile.com/cat-3/";

使用这个我在日志中获取数据..我使用了静态字符串并测试过你也可以使用 item.imgItem 值..

于 2012-11-10T09:49:58.757 回答
0

I checked your code and everything seems to be working. Please check imageData with NSLog(@"%u", [imageData length]);

于 2012-11-10T07:43:38.967 回答