Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Image is showing on simulator but not on a real iPhone

So I got this piece of code, I want to show a picture on my view:

imgLogo = [[UIImageView alloc] init];
[imgLogo setFrame:CGRectMake(60, 200, 200, 200)];
[imgLogo setImage:[UIImage imageNamed:@"MyFrigginAwesomeLogo"]];
[self.view addSubview:imgLogo];

But the problem is that it works correctly when testing it on the simulator(iOS 7) but it doesn't show anything on my iPhone(4S with iOS7) itself.

like image 412
Code Guru Avatar asked Sep 23 '13 18:09

Code Guru


2 Answers

Answer added from Comment:

The iOS devices are case sensitive, but the simulator is not. Make sure you are trying to load the exact filename in order for them to be found.

like image 185
Putz1103 Avatar answered Oct 27 '22 06:10

Putz1103


Try using the designated initializer for UIImageView instead of just init:

NSString *logoName = @"MyFriggingAwesomeLogo";
imgLogo = [[UIImageView alloc] initWithImage:[UIImage imageNamed:logoName]];
imgLogo.frame = CGRectOffset(imgLogo.frame, 60, 200);
[self.view addSubview:imgLogo];

It's also possible that you've added the image resource to only the simulator target. In your bundle settings Build Phases, make sure you have the image listed in Copy Bundle Resources.

like image 21
Ben S Avatar answered Oct 27 '22 08:10

Ben S