开发者

Image won't load in UIImageView iphone app

I'm trying to display an image in a UIImageView only in the first launch of the app. So after using NSUserDefaults to detect that successfully I try to load an image called firstLaunch.png in the MainViewController.

I created the UIImageView IBOutlet and connected and everything works fine but the image DOESN'T load. Though later somewhere else in my code I can update the UIImageView successfully. Here is my line where I try to load the开发者_高级运维 image to the UIImageView:

[countDownImage setImage:[UIImage imageWithContentsOfFile:@"firstLaunch.png"]];


You can try getting the path to the file.
So assuming the image is in the app bundle, get the path before with :

NSString *imgPath = [NSBundle mainBundle] pathForRessource:@"firstLaunch"
                                                    ofType:@"png"];
[countDownImage setImage:[UIImage imageWithContentsOfFile:imgPath]];

Another way is :

[countDownImage setImage:[UIImage imageNamed:@"firstLaunch.png"]];
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜