【发布时间】:2011-07-15 17:07:59
【问题描述】:
我正在尝试将图像加载到单元格中, 以下代码工作正常:
NSString *imageURL = @"http://localhost/images/image2.jpg";
NSData *imageData = [[NSData alloc] initWithContentsOfURL:[NSURL URLWithString:imageURL]];
UIImage *rowImage = [[UIImage alloc] initWithData:imageData];
cell.image=rowImage;
但是当我将 imageURL 更改为动态时,图像不会显示:
NSString *imageURL = [[stories objectAtIndex:indexPath.row] objectForKey:@"image"];
你可能会说问题出在:
[[stories objectAtIndex:indexPath.row] objectForKey:@"image"];
但它不是,我已经尝试记录它并且输出符合预期:
NSSLog(@"%@",[[stories objectAtIndex:indexPath.row] objectForKey:@"image"]);
//Outputs http://localhost/images/image2.jpg
可能出了什么问题?
【问题讨论】:
-
看起来不错。你从哪里得到
stories数组? -
它来自XMLParser委托方法,但它已经输出了值。
标签: objective-c xcode ios4 iphone-sdk-3.0