Image is showing on simulator but not on a real iPhone

℡╲_俬逩灬. 提交于 2019-12-06 19:42:47

问题


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.


回答1:


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.




回答2:


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.



来源:https://stackoverflow.com/questions/18965909/image-is-showing-on-simulator-but-not-on-a-real-iphone

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!