Displaying different images for iPhone 4 & 5 - ios

This seems to be an interesting problem that I'm getting. I'm developing an iPhone app for iOS 6+ devices and optimizing the images for both iPhone 4 & 5. Now I have implemented this into my project: Xcode 4.5 background image iPhone 4, 4s, 5
The problem is in interface builder I'm designing the UI with the iPhone 5 screen, so the UIImageView is 320x568. But when I test on iPhone 4, the image is being stretched and looks terrible. However, the specified image for the iPhone 4 screen is displaying, i just want its dimensions to be 320x480
Hope someone can help!

From the inspector view in the interface builder, you can edit the stretching behavior of the view when the size of the super view changes. You can click the red arrows inside the square to control that.
Also I suggest that you check UIView contentMode. You can edit that from the inspector view in the interface builder "third tab from the right.

In the UIImageView's inspector, try playing with the Mode property. The Aspect Fill or Aspect Fit may get what you're looking for to handle the different screen sizes.

Related

View goes out of order when change screen size ios

I am developing an app for ios. When I build it on simulator for 3.5 inch retina it works fine because I designed it for that in Interface Builder. But when I change simulator from 3.5 inch to 4 inch, components goes out of order. Here I have share snapshots:
3.5 Retina Image
Table view is highlighted in red box.
Retina 4 inch
Size of table view is increased but button is at old position. This is my problem.
Any suggestions?
Follow steps:
1. Go to your xib file
2. Select UITableView control from XIB
3. Then remove auto resizing mask from right side section
refer screen shot

How can I get the Xcode storyboard and the iPhone Retina (3.5-Inch) simulation to use the correct xcassets images?

Weird problem here which may be a bug in Xcode...
Using an Xcode 5.1.1 storyboard with auto layout, I am working on the design of a view controller that contains a full iPhone 4 sized UIImageView that references an xcassets image set. The xcassets image set includes 1x and 2x iPhone 3.5-inch images, and an iPhone 4 R4 image.
Problem 1: Once I set the Image View Image for the UIImageView in the utilities panel using a View Mode of Aspect Fit, the storyboard shows the smaller iPhone 3.5 image with white spaces at the top and the bottom of the view instead of the iPhone 4 image which would fill the entire storyboard representation of the view, as they are the same size since Xcode infers an iPhone 4 sized screen in the storyboard.
Problem 2: If I ignore problem 1 and run the program using the iPhone Retina (4-Inch) simulation, the applications selects the correct image size from xcassets and everything seems fine. However, if I run the simulation using the iPhone Retina (3.5-Inch) simulation, the applications also selects the correct sized image, but pushes the images down and display white space at the top of the page.
Before I start hacking around these problems, I thought I would reach out and see if anyone else has experienced either of these issues. Any help will be greatly appreciated.

Support of iPhone 4-inch screen by storyboard

I created a new project in XCode 5. And I run it on iPhone 5 (which has 4" screen) and a view doesn't cover all screen, but rather squeezed in 3.5" box (there are two black bars around my view)
I went to Main_iPhone.storyboard and checked that:
Use Autolayout is turned on on View Contoller
Use Autolayout is turned on on View
I tried Simulated Metrics, Size: Retina 4-inch Full Screen, Freeform and Inferred.
I tried to use button at the button to switch to Retina 4-inch form factor and 3.5-inch form factor.
Nothing makes a difference and it still shown as 3.5" (black bars around my view).
How can I make sure that iPhone storyboard occupies whole screen on iPhone 4-inch phone?
Update 1
None of solutions in this question: Xcode Storyboard displaying the new iPhone 5 screen size? solved my problem. BTW. That question was for pre XCode 5.
To enable your apps to work with iPhone 5, I suggest you to do two things.
First you need to add a retina version of the launcher image. It should be named Default-568h#2x.png.
And second use Auto Layout and make sure you have your autoresizing mask set up correctly for all your views.
I had the same problem, could not resolve it by any of the above methods. So what I did is copied the Content.json files from old project (where 4-inch was working) into the Images.xcassets Applcon.appiconset and LaunchImage.launchimage directories respectively. Then selected in the project setting in General under App Icon selected Source as AppIcon and in Launch Images in Source selected LaunchImage. It worked. Maybe useful to someone.

Two storyboards for different iPhones (3,5 and 4')

I write application for a 3.5-inch on one storyboard and for 4 inches in another stroryboard. As a delegate at startup check under what device is enter in and from there method can be carrying launch storyboard or iphone 4 or iphone 5
(because the larger screen iphone 5, can I expands the functionality?)
Is it correct?
You don't have to do this. There is a button in the bottom left of interface builder that lets you switch between screen sizes, and using autosizing will adjust it for both screen sizes.
You can also use Autolayout too

Simulator/device UI differs from storyboard

I am using Xcode 4.5.1 to create a very simple, single view iPhone app. I've laid out the view as you can see in the IB image. (UIViewController, UIView, UIButton, UITextView).
When I run the app in the simulator (or my phone) it looks like the second screen shot.
I don't understand why the simulator UI doesn't look like the one I created in IB.
What am I missing?
Thanks!
If you look you are using the iPhone 5 size layout in your storyboard file. To change the dimensions between iPhone 5 layout and the standard iPhone size
Click on the icon in the lower right hand corner of the storyboard:
Alternatively, if you want to see the layout in a iPhone 5 simulator. In the iOS simulator go to Hardware > Device > iPhone (Retina 4-inch). This is the iPhone 5 layout. However, if you do not have a retina displayed computer. The iPhone will look like a really big iPad.
It looks like you have an iPhone 5 sized layout in Xcode and a iphone 4 in simulator. Check the constraints on the dark grey vs bottom views and make sure that they'll resize how you want.
Hey so here is another method.
My Problem:
1.My Storyboard was showing a fat rectangle that didnt look anything like a iPhone. Then when I'd run the simulator all the element were cut off and not in the right position.
2.Simulator took up the whole screen.
Resolution:
1. Make sure you Storyboard is open and displayed, click on the frame so that it has a blue highlighted border. Then on the Utilities manager (on the right) click on "Show the Attributes menu". The very first item should be Simulated Metrics. Choose the size that best fits your screen/needs.
2.Follow Adjusting the XCode iPhone simulator scale and size I scaled it down to 33%
Best,
Nate

Resources