I have developed the IOS app, and it is my first app ever. I have 2 real devices. Iphone 5 and Iphone 6 plus.
I have created a UITable and in that under the custom cell I am showing small images let say 20 * 20 to represent something followed by its text.
For example I am using location icon and then I write its location in string. and both are horizontally aligned in a cell.
when I run it on the emulator Iphone 8, it shows the icon and the
screen design is as expected. but when I run it on my both devices it
is not showing me icons there it is only showing location in text form
but location image is just not there in both devices.
So I know I am doing something wrong so my summed up questions are
What is the size should I select as image/icons like button icons ?
how to put images in the project? I know it is like drag and drop in assets file? but is not there a way ?
I am not getting on how to make image and then postfix it with #2x #3x and from which size I need to start and then How to do it ?
I followed a tutorial over youtube but that was for app icon, and my app icon are visible on each devices, and looks good. But I am really confused about other icons that I have to use inside the app. and about their sizes and about how to put them in project
Please help me, and discuss it with me instead of links of pages because I have read too much on it but still a dumb head. please help me
Here is how to add an image to your project:
In the Project Navigator, open the Assets.xcassets by double-clicking on it.
Control-click in the blank area below AppIcon and select New Image Set from the pop-up.
A new asset called Image will appear. Click on Image and give it the name you want to use, (for example "house").
Drag and drop 2x and 3x PNG images into the appropriate spots. If your image is 20 x 20 points on screen, then your 2x image should be 40 x 40, and your 3x image should be 60 x 60. It is up to you to make sure those images have the proper detail and are not just scaled up low resolution images. (See Xcode images explanation for more background on 1x, 2x and 3x images).
In your code, you can load the image with let image = UIImage(named: "house") and iOS will select the proper resolution image for your device. The iPhone 5 will use the 2x version, and the iPhone 6 Plus will use the 3x version.
Related
I want to set a background image to my app but the image is not centered. The resolution is 640x1136, I have only one size, do I need more ? What is #2x and #3x ?
EDIT
I ended up spending ~ an hour in chat with the OP, and the solution to their problem was ultimately to remove all launch screen assets from the xc bundle and instead just put a UIImageView on the launch screen storyboard, anchor each side of it to the sides of the view, and set fill mode to aspect fill. That said, the below information is more likely to solve the problem for the majority of people who run into this, I think.
You need different sized images for the different screen sizes & aspect ratios. From the Apple docs:
It’s best to use an Xcode storyboard for your launch screen, but you can provide a set of static images if necessary. Create static images in different sizes for different devices, and be sure to include the status bar region.
The documentation includes a large table with all possible screen sizes one might support.
Many tutorials exist on the topic, and they may be a good place to start. This similar SO question also has a number of useful and informative answers.
Personally, I make one high-resolution image and then drop it into a tool which automatically generates all necessary screen sizes for me. I do the same thing for all the app icon sizes. Many such tools exist; SO is not an appropriate place to pontificate on which tools are better than others, so I will leave that choice (and research) up to you.
As far as where to put the images, the following instructions from Matthew Palmer's tutorial should be sufficient to get you started:
1 In Xcode, Click on your Assets file (Images.xcassets) in the left sidebar. It should open in the main pane.
2 In the left sidebar of the main pane (where AppIcon, LaunchImage, etc. are), right click
3 Select New Launch Image
4 Add your new launch images as normal. If you want something quick and easy to use, Paul Haddad recommends taking a screenshot in the iPhone 6 simulator and using that, or DavidSmith has created some default ones.
5 Change the Launch Images Source from your Target’s settings.
I found a useful list of launch screen resolution sizes here, which I will quote below:
Image Resolution Image name
320x480 Default.png
640x960 Default#2x.png
640x1136 Default-568h#2x.png
750x1334 Default-667h#2x.png
1242x2208 Default-736h#3x.png
768x1024 Default-Portrait.png
1024x768 Default-Landscape.png
1536x2048 Default-Portrait#2x.png
2048x1536 Default-Landscape#2x.png
The link where the above table was quoted from is also probably the best tutorial I was able to find on the topic. Note that, if you make the larger sizes first and drag them into Xcode, Xcode and auto-generate many of the smaller resolutions for you. (For example, providing one iPad resolution will typically be sufficient for all iPad resolutions.)
Ok let's take this one question at a time...
Background Image not being centered, I assume you have an ImageView containing that image... If so you should be able to do something like imageView.contentMode = .center
The #2x and #3x are for the newer phones with higher resolution. It is advised to have all 3. Also if you could show any code that would help.
I have an iOS application supports iOS7+, i am using now Xcode 7.
I have multiple image sizes to use for iPhone 4s, 5, 6 and 6plus sizes...
I am using image assets in XCode, but i found only 3 image nodes: 1x, 2x and 3x.
How to manipulate these different sizes with these only three options in image assets?
Edit:
in the story board; i have single viewController (assumption), this viewController contains single image, how to create single image set and put all images in this set and in the run time, every device takes its suitable image size?
In the "image assets" section of Xcode, you can add a different image set for each distinct image that you need in your app.
To add another image set for a different type of image you just click on the plus button in the bottom left of the image assets view, and then click on "New Image Set" (see image below).
From there you can add as many image sets as you would like, with the 1x, 2x and 3x for the respective devices. The 1x size represents images that will be used for non-retina displays (everything previous to the iPhone 4). Then the 2x size is used for all phones after that except for the iPhone 6 plus and 6s plus (those two use the 3x size).
Hope below mentioned link helps:
https://developer.apple.com/library/prerelease/ios/documentation/UserExperience/Conceptual/MobileHIG/IconMatrix.html#//apple_ref/doc/uid/TP40006556-CH27-SW1
I'm a bit confused here. If, say, I want to set an image as background (full screen) for my ios app (iphone), what are the sizes for the image I have to make? I googled and found no clear answer yet.
Using image assets gives no explanation either. I tried creating new image set, it just shows 3 slots for 1x, 2x, and 3x. How the xcode differentiate between what image to use for iphone 5 and iphone 6 (different ratio)?
EDIT
I seem to be unclear about my question. If the image for iphone 5 and 6 is the same, doesn't the aspect ratio differ? It will be stretched on one device or vice versa on the other and I don't want that. Back before the iphone 6, I just create image .png, #2x.png, and -568h#2x.png with the size 320x480, 640x960, and 640×1136. So my question is, for iphone 6 and 6+, what is the naming and size for my images?
If, say, I want to set an image as background (full screen) for my ios app (iphone), what are the sizes for the image I have to make?
You can use [UIScreen mainScreen].bounds's width & height to setup your view frame.
it just shows 3 slots for 1x, 2x, and 3x
They're not used for handling ratio of displaying, just for display solution (retina or not). You can just use xxx.png in your code, and it'll choose to use xxx#2x.png or xxx#3x.png appropriately.
How the xcode differentiate between what image to use for iphone 5 and iphone 6 (different ratio)?
UIImageView has an instance method called -setContentMode:, you can use UIViewContentModeScaleAspectFill mode for displaying in different devices w/ different ratio, i.e., some parts will be cut off.
This link should give you an overview of the differences between the 1x, 2x and the 3x image assets which we get once we create a new image asset.
http://9to5mac.com/2014/08/29/support-for-3x-image-assets-found-in-latest-ios-8-beta-ahead-of-larger-display-iphone-6/
Also when you create a new image asset, you can select image for specific devices such as (iPhone and iPad), if you are only developing for certain devices.
Select the devices as "Device Specific" from the Image Set Shown on the right side of the image.
As for you question, iPhone 5 and iPhone 6, xcode will take the same image assets i.e. 2x, for iPhone 6 Plus it takes the 3x image.
App Icon and Launch Image
Now for the App icon and the Launch image, this following link will guide you through.
http://www.iphonelife.com/blog/31369/unleash-your-inner-app-developer-managing-images-xcode-5-asset-catalogs
https://developer.apple.com/library/ios/documentation/UserExperience/Conceptual/MobileHIG/IconMatrix.html
for the launch image there are different options available, such as you can individually set images for the landscape and portrait images for different devices.
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
I am currently trying to push an app to the store (Build > Archive), but it keeps complaining about sizes of icons and certain sizes not actually existing.
I cannot find a slot in the Images.xcassets > App icon for a 120 or a 152, so first where do I put these icons so that it builds correctly.
Secondly, this is ridiculous, is there a photoshop script I can use that does the same icon up in 120, 152, and whatever other sizes it needs.
App script for photoshop
http://www.appsbynight.com/2012/09/17/create-every-ios-icon-for-your-app-with-a-photoshop-script/
Not used it, as I have a program on the Mac that converts it for me from a large image to smaller ones.. see below and is free...
https://itunes.apple.com/us/app/prepo/id476533227?mt=12
also the images to have #2x for the larger ons
so
icon-60.png
icon-60#2x.png (120 sized one)
This is not ridiculous.
2*60 = 120
2*76 = 152
Note that's said in "points" and not pixels. You have to check for the coefficient (x2 for Retina Display). Plus, since in iOS7 sizes changed, all iPhone/iPod Touch which can have iOS7 are Retina (that's why there is only the "x2" for iOS7 iPhone). For iPad, there is iPad Mini (non-retina).
I have modified an old photoshop script to create icons that have a size that matches the requirements in xcode 5.2
https://gist.github.com/derpest/8437300
Adding the correct icon to the correct place stops the errors upon validating to push to store.
A good explanation of this is explained here: 'Missing recommended icon file - The bundle does not contain an app icon for iPhone / iPod Touch of exactly '120x120' pixels, in .png format'
If you want an automated way to make your icons at all the right sizes, check out the App Icon Template. It’s a Photoshop file and a companion action that let you design your icon once, then export it all at once. Be warned that you may want to tweak your icons at each individual size to get the best look, but this is a good starting point because it lets you quickly preview your icon at all sizes.