【发布时间】:2012-07-04 13:36:45
【问题描述】:
下面的代码没有显示从网上下载并写入我的应用程序文档目录的图像。 我检查了iphone的模拟器文件目录里面,下载的文件是存在的。 但图像不显示。
当尝试使用UIImage *imgBack = [UIImage imageNamed:@"btn-back.png"];添加资源图片时,uiimageview会显示图片。但是从网上下载并存储在app目录中的图片不显示图片。
请告诉我,谢谢
NSString *workSpacePath=[[self applicationDocumentsDirectory] stringByAppendingPathComponent:theFileName];
NSLog(@"%@ workSpacePath ",workSpacePath);
if ( workSpacePath ){
//--------------
UIImage *imgBack = [UIImage imageNamed:@"btn-back.png"];
imageView1 = [[[UIImageView alloc] initWithFrame:CGRectMake(0,0,20,20)] autorelease];
[imageView1 setBackgroundColor:[UIColor grayColor]];
imageView1.image = [UIImage imageWithData:[NSData dataWithContentsOfFile:workSpacePath]];
[cell addSubview:imageView1];
}
【问题讨论】:
-
你检查过workSpacePath吗?是否显示图像的正确路径?
-
希望此链接对您有所帮助,stackoverflow.com/questions/2037432/…
-
是的,它显示了正确的路径
标签: iphone ios ios4 uiimageview