Making iPad app to support retina display - ios

I have made an iPad app and it works cool. Problem is that my client want's to have retina high resolutions also supported in the app. So lets say We are using images with normal resolution in the app are of 15mb , so again we need to add high resolution each file. So it will increase the file. Is there any way where we can just place high res files only and they should work on both retina and non-retina .

You can fetch image asset using [UIImage imageWithName] in that case, at the runtime appropriate image will be fetched for the device, i.e. if you'll use non-retina device it'll take 1x images and if you use retina device it'll use 2x images.
But, if you want you can fetch the file with [UIImage imageWithContentsOfFile:] you'll be able to fetch that particular file.
You can also use ImageOptim tool to optimse the image without image quality loss.

Related

Do I need to include images for a non-retina iPhone and 6+?

In my app I am using images of size 155*155pts so I am supplying it with an image of 310*310px resolution. I know that I can use image.png image#2x.png and image#3x.png and then [UIImage imageNamed: image] to select the image appropriate for the resolution. My question is do I really need to include a lower resolution version of size 155*155px, won't the UIImageView it's displayed in just scale it appropriately? A similar question for the iphone6+, if I don't include the #3x version will it just use the #2x and display it as clearly as a standard retina screen would?
Even though there are plenty of answers at SO discussing this topic
(Google them) e.g. How to handle image scale on all the available iPhone resolutions?
Its just a recommendation to to use scaled up images with #2x and #3x in your app. You don't have to create them. From my experience in making apps, in almost all of them I have never used multiple images. I create one UIImage and use it for all the phone sizes. I then either use auto layout or manually adjust the width height of UIImages myself.
There is a reason I do that is lets say one of your sample1.png image is 1MB then you will need to create 3 of them.
sample1.png
sample1#2x.png
sample1#3x.png
You just doubled or tripled your binary size which is bad for downloads. There always be users running non-retina devices and it would be shame to not support them. Can you only make retina enabled apps, of course you can and Apple will approve those as they will be testing your apps on the latest devices but the best approach is to support all devices.
It depends, if you only support non-retina devices you donĀ“t have to add the normal image size anymore.
The scaling for the 6+ works with the #2x images but i guess you will see a quality difference

Can we use just one set of image assert for all resolutions in iOS Development

I just want to use one set of image asserts for all iPhones and iPads(Universal), Is it possible to do the same? or what will be the best solution for the making a build lighter.
YES, it is possible ti use one image asserts for all devices. just add new image set
in assert by Right click. And the add images for required devices in created Image set.
you can use Image set but it's name,and images are automatically loaded with different devices.
UPDATED
if you want to titlelogo.png for all device then make new image set in Images.xcassets and name it as AssetTitlelogo. and the add all images in it as in screenshot.
You use image by
[UIImage imageNamed:#"AssetTitlelogo"]; /// use your asset Name
It's load right image for right Device..
Yes, if you use a retina image without the #2x or #3x in the name and your UIImageView is set to ScaleToFill it will automatically scale down your image on non-retina devices. it is easy to test with the simulators to see how the image will look at the different screen resolutions.
the trade off is non retina devices will suffer with more memory usage than is needed for them (and usually the non-retina devices are some what limited in memory already compared to the latest apple products) but if you arent dealing with a lot of images on the screen at once then this shouldnt have an adverse effect

Image looking blurry on non-retina iPad

I know I should have two versions of my image, one standarad and one #2x but my app downloads a vast amount of content which i need to optimise. Im looking at using just retina images in my downloaded content and then seeing if there is an objective c way to take a graphic half it and make it none retina. using a retina image on my non retina ipad looks blurry.
For images. You have to download separate images with your desired dimensions. For example Facebook timeline has separate image for user icon (e.g. 25x25). and For ever post having photo, a thumbnail is generated say it has dimensions (310x160). And then when a user clicks the image to view. It opens the original Image. Whatever dimensions it has. So, In your case. you have to download two images. One for your non retina and one for retina. You can use Flicker API's for that.
Note: You can skip this and continue with retina display because Non retina devices are rarely being used now. So, every one has retina device and app will work perfect with your existing scenario.

How important are non-retina images?

I'm releasing a new update for one of my apps and I was disappointed to see that it just barely surpasses 20MB estimated size (20MB is the point where it can no longer be downloaded over cell data).
My app contains a lot of images, so I could greatly reduce the size if I didn't have all those non-retina images. I know that there are some non-retina devices that will be running my app. So here are my questions:
How will a non-retina device react if I have an image with the #2x suffix but no non-retina image without it.
If I use a retina sized image without the #2x suffix and scale it down to the size I want to display it at programmatically and/or
through interface builder, will it still maintain full quality on
retina devices? Will the quality be worse on a non-retina device
than using an image I downscaled from the original using GIMP
instead?
How will a non-retina device react if I have an image with the #2x suffix but no non-retina i
image without it.
I use that approach on a couple of apps of mine and it works flawlessly. I am not able to detect any performance or visual issues on non-retina display devices (concretely, iPad 1/2 and mini).
I am not sure what can happen on older iOS version, since I only support iOS5+ on those apps.
If I use a retina sized image without the #2x suffix and scale it down to the size I want to display it at programmatically and/or through interface builder, will it still maintain full quality on retina devices? Will the quality be worse on a non-retina device than using an image I downscaled from the original using GIMP instead?
This comes down to how you set interpolation options while doing the scaling. See this other question for more details on how interpolation quality affects scaling down an image. In GIMP or Photoshop you also have control on the interpolation to be used for scaling, btw.
But in the end I don't think you need to go this way.
Most importantly, that bandwidth limit has been raised to 50MB.
OK.
If you only provide one image then you have one of two possibilities.
The image is a non-retina image. This will look fine on the non-retina. It will look identical on a retina device. But will look low quality next to a retina image.
The image is a retina image. On the retina device it will still load as a retina image. It will look fine. However, on the non-retina device it will have to scale down the image. This takes extra cycles of the CPU so could affect performance and it may not look how you want. It may shrink the image using a different method than you want and so may make the image look odd.
This is the same with or without a suffix.
The best solution is to create retina images and then use your editor of choice to create the standard versions. Nothing will stop you only providing one image but it may lead to a look and performance that you don't want.
On a side note. The size for downloading over cellular data was increased to 50MB.
Try these things using the simulator and find out for yourself.
I think the answer is that UIImage will ignore the #2x choice if you're relying on [UIImage imageNamed:#"without2xSuffix.png"] and not find anything, but I haven't tried it. Deliberately requesting the #2x file will work, but whether the image will be scaled, tiled, stretched or centered (or something else) is up to the place where it's used.
Note that the documentation says that unless you use the name without the #2x suffix and let iOS find the 2x version for you, it will set the scale of the image to 1.0 rather than 2.0, which complicates drawing. You'd have to load the image using imageWithData:scale: to fix this.

UITabBarItem Image Size

I am making images for my UITabBar. I am making them of size 60x60, because that's what retina screens use. However, when I use that size, it shows up too big in the bar, so you can only see part of the image. When I reduce it down to 30x30, it works, but that size is supposed to be for non-retina displays. Why does it not show up properly when I use 60x60?
You probably may have to rename your retina image to imagename#2x.png.
You were getting this behavior because you were supplying a high-resolution image, when iOS was looking for a standard resolution image.
iOS automatically selects the appropriate image size for you, depending on the resolution of the accessing device. So you will be responsible for supplying a "standard resolution" image, for non-retina devices, and a "high resolution" image, for retina displays. The way you do this in iOS is to append "#2x" to the end of your filename, but before the file extension, like this:
my-image.png // for non-retina displays (Ex: 30x30 dpi)
my-image#2x.png // for retina displays (Ex: 60x60 dpi)
my-image#3x.png // for retina displays(plus editions) (Ex: 90x90 dpi)
Then, when you are referencing files in your XCode project, you only need to supply the filename to the standard resolution (e.g, "my-image.png") and if the accessing device has a retina display, then XCode will automatically select the file with the "#2x" suffix for you. This is very convenient, because it saves us developers from having to detect whether or not the device has a retina display, and which image we need to supply.
Here is a code example:
// Select an image named "my-image.png"
UIImage *img = [UIImage imageNamed:#"my-image.png"];
// If the device this code is run on is a retina device,
// then Xcode will automatically search for "my-image#2x.png" and "my-image#3x.png"
// otherwise, it will use "my-image.png"
You can read more on the subject via the Apple Developer's Site: Optimizing for High Resolution

Resources