Layout for iphone 4, 4s and 5 on same storyboard - iphone

I'm making an app for iphone. My layout can be the same for iphone 4, 4s, and 5 but for the iphone 4 and 4s the only thing that change is space between buttons. I finished my app and i arrange all storyboard to run well on iphone 5. Now i only have to tell that when the app running on iphone 4 and 4s i have to change the space between the buttons in some views to get all buttons inside screen. How i can do this? I can use auto layout i think but i dont use this. Its possible to help me? I do the things right, doing the design first for iphone 5 and now adapt for iphone 4 or im doing the things in the wrong way.
Regards

The IOS6 autolayout it's still a bit "wild" and it will also disable the IOS5 compatibility.
If you don't use autolayout, you can still set some rules in storyboard at size inspector, like tide you buttons to the top or the bottom of the view, so you can control where they go when the screen shrinks.
A better way is to add subviews to your view, and allow the subviews to shrink and expand (also # size inspector in storyboard). Then add your buttons to those subviews, tide them to the top, bottom, or let them untied/free if they are placed symmetrically inside the subview.
You can simulate quickly with the form factor button in storyboard (right-down corner) to see where the buttons go when you switch the sizes.
These methods require zero lines of code, but more work with the storyboard.

Related

storyboard not autoresizing

On my phone the view seems to be zoomed in (to large for the screen)
Screenshot from iphone 5s
Compared to when Im building it in xcode:
i control clicked dragged every where and now it does auto layout itself

AutoLayout problems in iPhone5

I have a Xcode 4.5.2 Project
I have a story board with with four UIViews.
Autolayout is Set to ON in the StoryBoard
Deployment is iOS 6
I want the letterbox to appear on top and bottom when running on iPhone 5 and not have my views resized when running on a iPhone5
When I run my app in iPhone5 - I do not see the letterBox - the UIViews are automatically stretched (incorrectly)
When I run the App on iPhone 4 - Everything is as expected.
Why does the letterbox not show as I would expect?
If for some reason you want your app to behave on iPhone 5 the way older apps do -- automatically letterboxed by the OS to 3.5-inch screen dimensions, just don't include a Default-568h#2x.png in your app. However, Apple expects new apps submitted to the App Store to support 4-inch screens, so you might not get very far with this strategy if you're expecting to distribute your app that way.
If you want to "support" iPhone 5 (and iPod touch 5th generation) screens, but keep most of your UI at older screen sizes... well, your users may not like it (and the App Store reviewers might not either), but it's possible using Auto Layout. The catch is that the root view in your window's (or rather, your view controller's) view hierarchy is always automatically resized to fit the screen -- but there's no saying that has to be the main container for your actual UI content.
In IB, with the editor in 3.5 inch screen mode, drop a new UIView into your view controller's root view. It should automatically size to fill the screen (460 points high).
Add a Pin > Height constraint so the view stays 460 points high no matter how its superview gets resized.
Add an Align > Vertical Center in Container constraint so the view stays centered when the height of its superview changes.
Put all of your UI inside this view.
Now you'll get white bars (change the color of the root view if you like) above and below your UI when on iPhone 5.
Note this only works as long as your UI doesn't rotate to landscape. I don't think you can do this kind of artificial letterboxing for both orientations using only one set of constraints, so if you want to support rotation you'll need to respond to an orientation change by switching out constraints programmatically -- pin height and center vertically in portrait, pin width and center horizontally in landscape.

UIViewController Nib Layout changes at runtime

Notice the Nib on the left displays a layout with 2 UILabels, 1 UITextView and 2 buttons. The Y coordinate of the buttons changes at runtime. What is causing this and how do I fix it?
Update #1 - Problem goes away when I shift to a iPhone Retina 4-Inch display.
Update #2 SOLVED - Problem goes away when by unchecking 'Autolayout' in the xib properties.
It looks like you're using iOS 6 and a storyboard with the 4-inch "tall" iPhone screen form factor simulated. Assuming you are using Auto Layout, you probably have a constraint added to one or both of the buttons that pins them to the bottom of their superview. When you then run your app on the 3.5" screen iPhone simulator, the buttons appear to "move up" as their superview has gotten shorter than on your storyboard.
Find the button with the icon pictured below while editing your storyboard, and click it to toggle the simulated screen size between the 3.5-inch and 4-inch form factors. You should see your buttons re-layout based on their constraints.
To set your buttons' spacing relative to the top instead of bottom of their superview, select both buttons and from the menu bar choose the Editor menu > Pin > Top Space to Superview. (Or use the Pin button pictured below directly from the storyboard.)
There's a good introductory tutorial to Auto Layout here, if you haven't learned about it yet.

UITableView static cell resize for iPhone 5

I have seen the many threads on dealing with the iPhone 5 screen, and I have a Default-568h#2x.png added. The top view of my App resizes accordingly, but I have a container that contains a UITableViewController with static cells that gets more cells added when run on the iPhone 5. I need to have the static cells resize along with the rest of the app, so they occupy the same screen area.
Storyboard lets you toggle between 3.5 and 4 inch layout, but the changes you make carry over to the other, unlike when you rotate the view to adjust layout for screen rotation....
I found a lot about adding a second storyboard for the 5, but this seems like an inefficient way to do it. Is there any other way to get the static cells to resize accordingly? Thank you much!
Set rowHeight of your tableView to self.tableView.frame.size.height / 5

tranisition from iphone to ipad nibs

i am wondering how its possible to have an iphone nib that has some uitextfields and some labels to be automatically repotitioned if the device is an ipad. (i dont want a second nib) im trying to get my iphone nib to autoresize in the middle of the screen if the device is an ipad so that all the text fields and buttons arent placed in the top left corner. I tired using the autosizing masks however they wouldnt work for the textfield(im not sure why exactly the horizontal autoresize didnt work) is there any way i can do this without making a new nib if the device is an ipad?
thanks
I'm unsure if this would work, but you might try using a view that's the same size as the iPhone screen, set the autosize flags on that to keep it in the middle of the screen without stretching it, then put all of your views inside that view.