How to scale images to different iPhone screen using storyboards? - ios

I am developing an app in which i am displaying certain images such as delete icon,search icon.I have images by names are
delete.png
delete#2x.png
delete#3x.png
I have created images.xcassets & added the images in that for 1x,2x & 3x. Now i have added an UIImageView on story board & it's default image is delete.png(32*32) it runs fine on 3.5 inch screen but images does not scale on 4.7 & 5.5 inch screen iPhone. Can some one please help me out.What to & how to do it?

I thick #Banning and #Fatti Khan suggestion will be the solution of the problem.
Instead of using image name as delete.png use just delete
as a ratio set the images with the exact size as example if the 1x image is 30 px then 2x must be 60px and 3x 90px
1x images are for the original iPhone through the 3GS - 'standard' resolution devices (3.5" screens)
2x images are for the iPhone 4, 4S (3.5" Retina screens) and also iPhone 6.
Retina 4 2x are for the iPhone 5 and 5s (4" Retina screens)
3x images are for the new iPhone 6+ (5.5" super-Retina [3x] screen)
EDIT:
please clean your project and then check again (cmd+shift+k) of delete your derived data.
also check your view is autolayout enable or disable.
or
add The launch image Default-568h#2x.png as i thought your Code unable to detect the different type of screens it have,so follow this steps
First I would like to suggest that,
Preapre all Images,
Select Project from Project Navigator And Go to Summary and scroll down this
screen appears, then right click on that and choose file from your
computer it will automatically copied to project and it will entered
in plist file also..
if your application is universal then you have
to set for iPhone and iPad Both.

Related

stretch old iOS app on iPhone6 Plus screen

I have a very old xcode/objective-c iOS project.
I tried to compile it on the lastest Xcode version and it works fine.
On big iPhones, the application is streched to fit in bigger screen.
I tried to create a new Xcode projet and drag all my source files in the new project. I removed storyboard.
It works, but the application is not stretched. I see 2 black bands at the top and the bottom of the screen.
What i want is just to understand which parameter i have to changed in the project.
This is not a storyboard or size classes issue because i have no storyboard or xib files. I tried to change iOS version déployment target.
Thanks
You need to add a launch image for the large screen size of the plus models or better a launch screen file.
See: here
Add launch images of of accurate sizes as follows for iOS 8 and later.
Goto launchScreen in the XCAssets, you can see these options on the right pane see the image attached.
and add images with size :-
Image type Size
Retina HD 5.5″ 1242 × 2208 pixels
Retina HD 4.7″ 750 × 1334 pixels

Swift - Images Distortion in universal app

I have created iPhone app with a lot of images as interface details. After completion, i decided that i also want to support iPad. So in size classes i chosen REG REG and edited constraints for new device.
Now I have a problem. All images in iPad mode are distorted. Absolutely all. I test on iPad 2 and physical iPad mini. For example I have a png with text
here it is on iPhone 6+
here of iPad2
as you see on iPhone it is smooth, but on iPad pixellizated.
And that happens to all images
Why can this happen ?
As the resolution of both, iPad and iPhone differ from each other, and you are comparing an image of iPhone6+ with iPad, so iPhone6+ will take #3x image while your iPad mini and iPad 2 will take the images of size #2x(if they are retina). So to support the image for iPad you have to add the images for iPad in your images.xcassets folder if your are using the xcassets like this
To get the options for images you have to select your xcassets folder then from the attribute inspector you have to check iPad.

Make iPhone 6/6 plus resize apps automatically

All my old apps are looking good on iPhone6/6+. But when I create new project iPhone 6/6+ treat apps natively. So they look awful. Instead of trying to adjust views using constraints and stuff, I decided it would be better to write app for iPhone 5 and let new iPhones scale it. I know solution is not perfect but is good enought for me. The questions is how to make new iPhones treat my app as iPhone 5 app. How to make them scale it?
Thank you.
You have to provide a LaunchImage with the correct size :
iPhone 6 Splash screen 750 x 1334
iPhone 6 Plus landscape Splash screen 2208 x 1242
iPhone 6 Plus portrait Splash screen 1242 x 2208
I'm answering this by memory as I don't have xcode in front of me, but I'm quite sure it's correct.
You need to create and add 3 launch images to your project of the following sizes:
*640x1136
*640x960
*320x480
Go to project settings, general and select the launch image source option. Select use asset catalog, and create an asset catalog if you don't already have one.
With the asset catalog open you should have a section called launch images, if you do not, tap the '+' button in the bottom left hand corner and add the launch images option to your project. Select the launch images option.
The top row of images are used for iPhone 6/6 Plus, leave these blank. Drag and drop the launch images that you created onto the bottom two rows of images.
Return to your project settings and select the launch screen file option. Remove everything - ensure that the selection is blank. (To do this I selected my main.storyboard and just deleted the text in the text box).
And that's it, now you can automatically zoom your app on the larger devices.
Hope this helps.

Launch Screen Image size for all iOS screen sizes

I am trying to create a lunch screen image for my iOS app. But I am not sure whats the right size for it.
According to apple website for iPhone 6 the size should be 750 x 1334 (#2x) for portrait.
But my question is, how to create a launch screen image that will fit for all screen sizes such as iPhone 5, 5s, 6, 6 plus, iPads etc?
Whats the correct way of doing this?
Go to images.xcassets
there you can see launch image sizes.Just Enable iOS version from right side.
iPhone Portrait iOS 8:- 1242*2208 (5.5 inch)
750*1334 (4.7 HD)
iPhone Landscape iOS 8:-2208*1242 (5.5inch)
iphone Portrait iOS 7,8 :- 640*960 (#2x)
640*1136 (Retina)
iPhone Portrait 5,6 :- 320*480 (#x)
640*960 (#2x)
640*1136 (retina4)
But my question is, how to create a launch screen image that will fit
for all screen sizes such as iPhone 5, 5s, 6, 6 plus, iPads etc?
That will be very hard to do. The devices have different aspect ratios and the difference in size between say iPhone 5 and iPad Air is pretty big to use one image for all. If you want to use the classical launch screen with a screenshot, resizing one image won't look the same as the user interface on different devices. If you want a launch bitmap image you will need to supply all the necessary sizes.
Whats the correct way of doing this?
You can create either launch PNG image or launch screen as a storyboard.
For launch image, your project has an assets catalog. Either use existing or add new iOS launch image. The editor will show you all required sizes.
For a storyboard, your application probably already has LaunchScreen.storyboard. You typically won't create specific size or sizes here, but use auto layout that will resize the screen appropriately.

how to get a normal keypad on iphone 6 and 6 plus

I'm building an app that works fine on iphone 5. When I look at it on a iphone 6 or 6 plus however, I see that the keypad is stretched, basically zoomed in. I'm using autolayout and storyboards.
What do I need to set in order to make the keyboard scale to a normal size?
You need to ensure that the app is optimized to run in the native resolution of these devices, rather than the zoomed compatibility mode. This can be done by setting a properly-sized launch image for the iPhone 6/6+.
These launch images will be labeled Retina HD 4.7 and Retina HD 5.5 in your launch images file, respectively. If you do not see these options available in your launch image assets, create a new launch image set and they should be there.

Resources