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"]];
精彩评论