Mad*_*han 5 iphone objective-c uiimageview
在iPhone中显示图像时遇到问题。我使用了以下代码,但仅适用于.png文件。
UIImageView* imageView=[[UIImageView alloc] initWithFrame:CGRectMake(6,10, 80, 80)];
imageView.image = [UIImage imageWithData:[NSData dataWithContentsOfURL:[NSURL URLWithString:customerListObject.customerImage]]];
[myView addSubview:imageView];
[imageView release];
Run Code Online (Sandbox Code Playgroud)
我无法显示其他类型的图像文件,请提出解决方案。
谢谢,Madan Mohan
小智 2
尝试使用这个:
imageView.image = [UIImage imageWithContentsOfFile: [[NSBundle mainBundle] pathForResource:@"imagename" ofType:@"png"]];
Run Code Online (Sandbox Code Playgroud)
然后将 imagename 和 png 替换为您的文件名和类型。
| 归档时间: |
|
| 查看次数: |
5714 次 |
| 最近记录: |