我在 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];
我无法显示其他类型的图像文件,请建议我解决方案。
谢谢你,
马丹·莫汉
尝试使用这个:
imageView.image = [UIImage imageWithContentsOfFile: [[NSBundle mainBundle] pathForResource:@"imagename" ofType:@"png"]];
然后将 imagename 和 png 替换为您的文件名和类型。
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)