I am not sure if this is the solution for this problem as I am missing some information, but:
First: split the .png using the imageNamed: method. Starting with iOS4, you should no longer do this. Next: What are the names of your image? Please note that iPhone5 has a retina display, and your image should be named bg-for5-568h@2x.png , but indicated in the source code as bg-for5-568h .
In addition: in almost every case when your image is not a photograph, what you do is a bad idea. And even if it's a photo, just use the larger image for the iPhone 4 and 4S. This is not much more, so memory is not a problem here! Take a look at the UIImageView contentMode property. You can use this to adjust the position of a larger image. You can also check the UIImageView clipSubviews property to crop the image if it is not full-screen.
Believe me, in my company we had a huge number of hooks for things like ~ ipad, ~ iphone, ~ 2x and even stretchable images. And all these hooks worked perfectly up to date, Apple announced something similar or just a new device. So I decided not to make such hooks anymore. They seem to be very useful in the first place, but the problems you get when there is something new in the market are not worth it!
Michael Ochs
source share