Tan*_*ner 12 xcode objective-c uiimage imagenamed initwithcontentsoffile
我有疑问:我想避免[UIImage imageNamed:].所以我做了:
UIImage *prodImg = [[UIImage alloc] initWithContentsOfFile:@"myimage.png"];
controller.productImg.image = prodImg;
[prodImg release];
Run Code Online (Sandbox Code Playgroud)
但现在图像不再显示了.
有谁知道如何让它工作?
Dev*_*shi 25
上述代码无效,因为正确的方法是 -
NSString *thePath = [[NSBundle mainBundle] pathForResource:@"default" ofType:@"jpeg"];
UIImage *prodImg = [UIImage imageWithContentsOfFile:thePath];
controller.productImg.image = prodImg;
[prodImg release];
Run Code Online (Sandbox Code Playgroud)
;)
| 归档时间: |
|
| 查看次数: |
13274 次 |
| 最近记录: |