Imagenamed: Method return nil often has the following situations:
Item does not exist for this picture;
The picture is not named correctly;
There is a problem with the suffix of the picture (often using a. png image, a picture with a. jpg suffix may be problematic);
The device is using a Retina screen, but the project does not provide a corresponding @2x image;
Excluding these common situations, my imagenamed: The method still returns nil.
Finally, uninstall the app from Simulator, Exit Simulator, close and restart the Xcode,clean project, recompile, run! The tragedy is still not good.
Is there something wrong with the editor? So I commented on the code and wrote it again on the next line.
UIImage *imageforbutton = [UIImage imagenamed:@ "Recharge"]; UIImage *imageforbutton = [UIImage imagenamed:@ "Recharge"];
It worked! The feeling was played by Xcode again.
My knowledge is relatively shallow, do not know the real reason for this problem is what, but if you also encounter this dilemma, may wish to try this method. Maybe Xcode is making fun of you.
This article is from "Happy coding ..." Blog, be sure to keep this source http://jiataozhou.blog.51cto.com/7355162/1684543
Xcode bug:imagenamed: Method returns nil