set 1024*780 Image for all the iDevices - ios

I Just started developing an Universal iOS app for which I need to set the Background image.
Instead of using 3~4 different size images for iPhone, iPhone-retina, iPhone5 , iPhone5-retina & iPad, iPad-retina , I Just want to take one Highest resolution Image (say 1024*780), Which I want to use to fit all the above mentioned devices. How???
self.view.backgroundColor = [UIColor colorWithPatternImage:[UIImage imageNamed:#"sfond-appz.png"]];
& it is not occupying the exact screen size for smaller devices. it is shrinking.
Please Advice!!!

If Apple suggests to use different images for each kind of display there is a specific reason, and that reason is memory.
As display size increases it increases also the memory available on the device that's because bigger images require more memory. Even if you want to resize (not stretching) them at runtime, the first time you open it will occupy that memory until you release it. The memory occupied it doesn't have to deal with the file size.
If you still want to try take a look at this library that will help you to resize (not stretch) images at runtime NYXImagesKit

I'm doing the same thing in one of my apps in the App Store. On the main menu view, I use a UIImaveView as the background and set the mode to Aspect Fit in Interface Builder. I use struts and springs to keep it aligned to the edges.
For a universal app, you'll create this UIImageView on both the iPhone and iPad story board (or .xib files) and use the same image file.
However, I still have a 2x version for retina displays. So, I use just two images to cover all devices, orientations, and resolutions.
It will consume less memory if you create a background image to fit each device, but you will obviously increase the bundle size. In my case, the goal was to keep the bundle size small (under 50 MB for cellular delivery), and I had memory to spare.

Related

iOS ideal image resolution

I'm having a real hard time understanding this, but let's say I have an iOS app for both iPad and iPhone and I want to download an image from a server and display it in full screen.
I have read that the iPad pro has a resolution of 2732x2048 and if we want to display an image in fullscreen we would need to download the image with this size right? However, I also read that the image should never be over 300KB. I was not able to bring an image with this size under 2MB (I used JPEGmini for example to reduce size).
And I don't think that iPhone user would need to download such a huge image, so my question is: what resolution should my images be on the server and how can I manage to keep them in a rational file size. Also should I upload multiple images for different devices? If so, how many and at what resolutions?
Isn't the problem merely that you are holding incompatible beliefs? This is the belief that is giving you trouble:
I also read that the image should never be over 300KB.
Let go of it.
Clearly it is right to say that the image should be no larger than needed for display. But an image to be shown as a 3x scale image on the iPad pro needs to be 2732x2048. So that's that.
(You could, alternatively, use an image 2/3 of that size and show it as a 2x scale image. It wouldn't look quite as good as the 3x scale image, but it might be acceptable.)
On a smaller device, yes, you should scale down the image in code, so that you are not holding in memory an image larger than needed for display. But in this case, you need the large image for display.

How to include full screen image in an iOS App

I want to add a full screen image into an iOS app and I want to know the best way to support different devices
The problem with using the image assets: 1x, 2x, and 3x is that 2x is used for iPhone4s, iPhone5, and iPhone6 which every one of them has a different dimensions
Should I use a different images (one for every device) and include them as resources then at runtime I choose the image based on the current device? I feel like it is not a good solution
any suggestions of a more elegant way?
If you click on the asset you can configure more options and sizes depending on various parameters. Conceptually similar to what happens when you create a new LaunchScreen Item in the asset. See image.
Depending on what is the wanted end results you can also adopt different tactiques, like having a background image that is big enough to be set as "Center" aspect mode and the eventually place other images like logos or titles on top of it. Or again just have one big image that can be set as "AspectFit".
It's not a good idea to have a different image for every device. Either use stretching or tiling to handle different sizes, or make an image that you can clip on smaller screen sizes, or you will have to have different images for each device and code to detect which to use and spend time maintaining that whenever new devices are announced.

Images.xcassets in Xcode 6

I am trying to figure out how to use the xcassets folder in Xcode 6 and I have to say Apple could have done a way better job. I'm a big fan of Xcode but their images storage per type of screen / phone is a nightmare.
First, in my application I am using images which will have a height of half their width. From what I understood, taking pictures of around 1200x600px should do for all types of iphones (full width minus small margin). So I put them in 3x universal, right? If I gave the maximum size why would apple need 1x and 2x ...? Just resize it yourself, no? Is it compulsory for me to give something or will it work by itself? Images are not vector but simple PNGs. In the simulator nothing is complaining and it works well for all types of iphones. Is it okay to leave the other two empty? From I see from the simulator iphone 6 will use downsized #3x images so what is the point of having two images? Only ratio is important and they have the same ...
Secondly, I just added today a launch screen for retina hd 5.5 / 4.7 and now when I run the app in the simulator my uitableviews only take around 4/5 of the full width instead of full width .... can't figure out why adding a launch screen would modify layout of my uitableviews ....? Navigation bar and other screens seem untouched though ...
Any help appreciated.
you need to add the images for the 2x & 3x because when you add large size image then at the run time this image get resize as per the actual width of the image it utilize memory lots of memory to do this & some time if your application have too many images then you will get memory issues
if you want to test this then run your application in iPhone 5 then see the memory utilisation by first keeping the high resolution image now take image which will be of appropriate size to iPhone 5 & then run again you will see the difference
so the best practice is to use different image for different size & not images in this fashion.
The answer to your second Question
if you are not adding the splash screen for iPhone 6/6+ then iOS stretches your UI of iphone 5 to fit into the size of the iPhone 6/6+.
But when you add splash screen it stops doing that.
late to the party but yes you need to manage all this resolution by yourself. Otherwise it will consume more memory.
but yes there is one tool which will make your work less by generating all assets for you
AVXCassets Generator

Background image for iPhones and iPads of various sizes

I would like to add a background image for iOS and I want the background image to have appropriate resolutions for all tablet and phone versions. What design considerations should I take into account? What resolution should the image be in?
This the list of current screen resolutions for the variety of devices: click for resolutions
You could create 10 different images, 5 each for the landscape and portrait views.
Alternatively, you could create 2 or 4 images to cater for the landscape and portrait views and use code to check the devices size to size them appropriately.
The advantages of creating all the right sized images means that you have a precise background that is consistent across all devices, especially if you have logo's in the background as distortion may occur with resizing of images across devices.
Conversely, creating only 2-4 images should reduce memory size as the app downloaded will only be packaged with those background images instead of 10, and if resized correctly, shouldn't look to out of place.
I would test the 2-4 images using simulator, checking the look and performance on all devices you plan to release to. If you aren't happy, either customise your layouts for the images so they stretch to fit appropriately, or, for symmetry across all devices, I would create all the images and package, with an attempt to reduce the size of each image to be perfectly aligned with the device boundaries to reduce memory consumption.
The disadvantage of using 10 different images is the extra code required to fit, and should a new device size come out, you will need to create additional images, which ultimately consumes more memory and requires long term monitoring. It also consumes unnecessary memory if you are using an iPhone 6 and have images for all the other devices.
My advice - weight up whether you really need the background and if so, whether or not resizing just 2 images to fit any device will impact the look of your app.

Is it the "weight" or height and width that matters

I'm developing a game with lots of graphics for iOS platform. None of the graphics are dynamic, they're all ready made images. There are 6 layers on the screen and each layer contains 3-4 graphics objects in average that constantly scroll to left, each with different speeds. So with each screen refresh about 20-25 objects are scrolled, removed from screen and added again from right. The game is universal so images of all sizes present in the resources folder.On iPads, iPhone 5, iPhone 5s it goes smooth. But on 4th Gen iPod touch I notice some hiccup.
When I test the app with Instruments, I notice a critic memory problem at start and then the problem goes away. So this is all because I load all the above graphics on application start. All the images are combined into 4 different sprite sheets. So here's my question:
Is it the weight in kilobytes that matters or is it the dimensions? I'm asking this because I reduced the size of the images by about 70-80 percents, though their height and width remain the same, but that memory problem still exists.
If you are reducing the size of the images by utilizing compression, then expect there to be delay and a memory hit as the images are uncompressed when first loaded, and they will take up as much memory as they did before compression.
The 4th generation iPod Touch probably is having some memory pressures and it will try to release memory elsewhere in order to allow for your images to load up and stay in memory. That may be the hiccup you see, as other apps, like Mobile Safari or Mail are asked to give up some memory or to terminate.
(The size the images take in the resources folder is inconsequential. It is the size they take when they are uncompressed and in memory that matters).
You could make the images smaller by making them 4bit instead of 8bit color, or you could make them monochrome. You can also use a non-retina size or smaller, and then let the OS stretch them out to fit the space required. I would try to use the best images first, and if you get a memory warning (didReceiveMemoryWarning), then reload with the images that are less dense.
you can not load all image before the game beginning, you should use the cache to control the size of the memory. And before the scenery of game change ,the release the cache ,reload the need ones.
So you must control your resource dependents in the every game scenery.
This is the common method to management the large resource application.

Resources