Reputation: 535
As you can see, that I have put my the national flags in a folder in Xcode and I am trying to display it to the navigation bar. However, it is not showing up and I found out:
NSString *imageName = [NSString stringWithFormat:@"%@.icns",countryName];
UIImage *image = [UIImage imageWithContentsOfFile:imageName];
image is "nil".
Any idea? Thanks!
Upvotes: 0
Views: 3215
Reputation: 4921
Where was the image path you are sending NSString to here
UIImage imageWithContentsOfFile:imageName
send the path to that method. or make like this
UIImage *image = [UIImage imageNamed:[NSString stringwithFormat:@"%@.icns",countryName]];
Upvotes: 1
Reputation:
You could use like this
NSString *imageName = [NSString stringWithFormat:@"%@.icns",countryName];
UIImage *image = [UIImage imageNamed:imageName];
Please Try This
Upvotes: 1
Reputation: 9902
Check whether the file actually exists. I suspect it doesn't. Use [NSFileManager defaultManager] fileExistsAtPath:
.
Upvotes: 1