我有一个问题:我想避免UIImage imageNamed:。所以我就这么做了:
UIImage *prodImg = [[UIImage alloc] initWithContentsOfFile:@"myimage.png"];
controller.productImg.image = prodImg;
[prodImg release];但现在图像不再显示。
有谁知道怎么让它工作吗?
发布于 2011-09-23 15:24:21
上面的代码不起作用,因为正确的方法是-
NSString *thePath = [[NSBundle mainBundle] pathForResource:@"default" ofType:@"jpeg"];
UIImage *prodImg = [UIImage imageWithContentsOfFile:thePath];
controller.productImg.image = prodImg;
[prodImg release];;)
https://stackoverflow.com/questions/7525348
复制相似问题