In an app I am working on, iOS seems to be choosing the #1x images over the #2x images to display on an iPhone 6+ (picks #2x properly for a normal retina 2.0 scale screen). It was not always doing this though. I am not sure if the trigger was me adding a few #3x images or upgrading to 8.1 - both were done on the same day and I did not test on device until both had been done in several places.
Anyone else seeing this?
I'm having a similar issue with the iPhone 6 Plus running iOS 8.1, built with Xcode v6.1. The problem affects images used from the bundle, but doesn't seem to affect those in an asset catalog.
If only the 1x image is available, it uses the 1x image, as expected.
If only 1x and 2x are available, it strangely uses the 1x instead of 2x.
If 1x, 2x, and 3x are available, it uses the 3x, as expected.
I put together a quick asset test that I've uploaded to GitHub.
A workaround is, to set the images via myImage=[UIImage imageNamed:#"foo.png"];
Like so, the #2x images are taken, when no #3x is available.
You can do this recursively for every screen.
iOS 8.1.1 resolved this. It was clearly an iOS bug that Apple has now fixed!
Related
In the last 6 months I have been able to make a pretty good app in iOS Swift. But Now I want to touch upon some performance and best practices in development.
So I wanted to know what is the best practice of using images in Xcode? To be specific, I usually drag and drop images in my project folder to use it inside my app. But I know that we can also use image.xcassets to do the same thing.
The question is, which one is the right way? Or which one should be used when?
I have seen in image.xcassets we have to provide 3 images. 1x, 2x and 3x. Does that mean that I am increasing the size of the app (considering I am using many images)? Also how does it effect the performance? Is there any difference in fetching the file from project folder or from image.xcassets?
On the top of my head "Image.xcassets" has a bug in Xcode 6 where you cannot load JPEG images. Other than that, it is the best practice of organizing your images. The 1x, 2x, 3x are for the different screen resolutions of iOS devices. 3x images load on iPhone 6 Plus, 2x on any device with a retina screen (iPhone 6, iPhone 5/5s/5c, iPhone 4/4s, etc), and 1x on some of the older iPads and iPhones
I want to update an app which was developed before there were #3x assets. Will my app get rejected if I don't include a #3x version for every image?
No, the #3x suffix is only recommended if you're supporting iPhone 6+ (iOS 8+) although not required at the current time. Below are the requirements and recommendations for image sizes.
Icon and Image Sizes
If your application supports the device running iOS 7, then it will not get rejected. One of my application was recently approved (a month ago), which doesn't contain any #3x images.
But it needs to be confirmed for the application that developed in iOS 8.
Edit
For your information:
My application was already on AppStore and It was an update.
Found from What's new on iOS 8
Support for a New Screen Scale
The iPhone 6 Plus uses a new Retina HD display with a screen scale of 3.0. To provide the best possible experience on these devices, including new artwork designed for this screen scale. In Xcode 6, asset catalogs can include images at 1x, 2x, and 3x sizes; simply add the new image assets and iOS will choose the correct assets when running on an iPhone 6 Plus. The image loading behavior in iOS also recognizes an #3x suffix.
I fear that you need to provide #3x images for all asset images if you are going to publish your application for iOS 8.0 and for iPhone 6 plus device. As it clearly says that "The image loading behavior in iOS also recognizes an #3x suffix".
I suggest you include #3x images before going for approval.
My app is optimized for iPhone 6/6+ using the appropriate launch screen images. I did notice an interesting behavior though. I am no longer supporting non-retina screens so I deleted an image.png for which I had included in my bundle an image#2x.png but not an image#3x.png. I build and ran on an iPhone 6, expected behavior.
I build and ran on an iPhone 6+ and the image was missing completely. I ran again on 6+ simulator and the image showed. I added image#3x.png and back to expected behavior on both simulator and device. I don't recall it being this way with image to image#2x, for example if i had image it would just scale up to 2x if I did not include an image#2x.
For the sake of experiment I deleted image#3x.png and added back image.png, ran on device, image appears. Does this mean that images are being scaled from 1x to 3x? Seems it would make more sense to me to scale the 2x image to 3x?
I've just tested more by deleting image#3x.png and altering image.png but not image#2x.png. I can verify that it does use image#2x.png to scale, but for some reason image.png must be included if image#3x.png is not. I guess in this case I would just rename #2x to just.png
Because I made app (iphone) myself, with 200 images, I want not using non retina images.
It may be for me big problem to resize images for non retina display.
I don't have non retina display iphone, to test it.
Must I add non retina images to xcode, or not?
If I don’t add them, must I add “#2x” to all images for retina?
I tried my best to find answer for my question but there was no clear answer.
Thx for answers.
I thing it will be better make non retina display images, than buy non retina device for testing how it looks.
I have another question:
Button background needs #2x images and non retina display background images?
You must add non-retina images if the platform your targeting includes non retina devices (e.g. iOS 6 and earlier or iOS 7 iPad). If you do not, non-retina devices may not render your app correctly.
If you are not targeting a platform that supports non-retina devices (Eg iOS 7 iPhone), you may omit non-retina images. Your retina images will still need the "#2x" suffix in the file name for the system to find them.
I read somewhere that if you do not include non-retina images, the iOS will use the #2x images, scale them on the fly to non-retina sizes, but that may affect performance. Make sure you test on at least one non-retina Device to make sure it works.
This should not be too much of an issue. Test your app on the simulator using non retina and make sure your images are showing up properly. Your images should scale and won't cause a problem. It would be better if you could have both retina and non retina images but not a game beaker.
I have *#2x version of every image I use in my app and as long as I test in simulator everything works fine. But for some reason on my iPod 4 (non-retina) app not only loads wrong images, but also scales them about 4 times their accual size. Answer given in this topic would help with scaling problem, but I still have to solve non-retina - retina issue.
you need to have two files one for retina and other for non-retina display
ex:
myImage#2x.png (bigger file for retina)
myImage.png (smaller file for non-retina)
and then just call [UIImage imageNamed:#"myImage"]
it should work
*make sure to clean everything, and try again.. hope that helps.
you have to make background.png (320-480) for non-retina. and background#2x.png (640-960) for retina, if you want to develope for iphone5 too you have to make a background-568h#2x.png (640-1136) too