I have a Universal application in Swift 2.0 developed in XCode 7.
On the storyboard simulated metrics, I have the 'size' set to 'iPhone 4.7-inch'.
When I run the application on my device (iPhone 5s), none of the labels are aligned and the toolbar is out of view. -This is also the case when I run using the iPad device in XCodes simulator.
Image of what the view controller contains ...
From the snippet above, when I run this VC on my iPhone there is no margin on the right side, and the toolbar is cropped off.
Can anyone advise how I can make a universal application show all the content in the VC, on all devices. Or how I would simply show the toolbar ...
That's what auto layout (constraints) is for.
On the storyboard simulated metrics, I have the 'size' set to 'iPhone 4.7-inch'.
That's irrelevant, and indeed misleading, since in means that only on the iPhone 4.7-inch will your app look like the storyboard design — unless you use auto layout.
iPhones come in many screen sizes. Basically, you have no way of knowing, as you design, what the screen size will actually be! Auto layout is the solution. Auto layout allows your interface elements to adjust automatically as the app launches on a particular size screen. iPads can serve as an extension of this — i.e., just an even larger size screen — or you can even use conditional constraints to make the interface quite different on the iPad from the iPhone, if desired - all designed in a single storyboard.
Maybe you are using auto layout and auto constraint. You could deactivate this in opening the storyboard, open up right panel , go to "show the file inspector" section and under Interface Builder Document uncheck auto layout and auto constraint
Image here
Select your item view, go into "Show the size inspector" and there you can set your autoresizing for all devices
Related
On a test drive app, I have a basic UIViewController (QZTestViewController) loaded with its xib file with only one UILabel centered by autolayout. This controller is opened from the home controller (QZHomeViewController designed in the default storyboard).
The problem is that the height of this label is smaller that the result on the simulator. See it in XIB/Simulator comparison snapshot.
Any idea ? A small test project is available here if someone can have a look and help me before I become crazy.
PS: Note that the simulated metrics is set to iPhone 5.5-inch in the XIB file and I run the simulator iPhone 6s Plus (9.3).
From the size of the status bar items on the Simulator (and double-checking your project), I can tell that your app is being upscaled to fit the screen. This is happening because it's not properly configured to the 4.7" or 5.5" screens.
To fix that and make it load with the correct resolution, simply add a LaunchScreen storyboard to your project. Go to your project settings, select your Target and in App Icons and Launch Images select a storyboard or xib file to Launch Screen File. This will make the app compatible with the larger screens' resolutions, and your button will have the correct size as it will not be upscaled :)
I am designing layout for iphones and for tablets using the Any * Compact and Regular * Regular of the Xcode story board
The problem is that outlets that i created in the iphones screen dont work in the tablets screens
Its like they are not connected and if i drag and connect them again to code it will work for the new connected layout devices but not on the old ones
How to solve this?
If you use Any Any your outlets and elements on Storyboard will be available to all layouts, when you start qualifying device or layout sizing then the elements on that layout will only be available in that size.
Make all the general configuration that will be same for all screens in Any Any . Then from that configure specific alterations that are needed for Iphones in landscape , portrait and Ipad landscape and portrait respectively
I am trying to work with Xcode 6.1. How can I use different storyboards for iPhone and iPad in Xcode 6.1? I mean, I want to create two different storyboards for iPhone and iPad, and the app will determine which storyboard is to be presented when launching.
I know that I can turn "Use Size Classes"(in the settings of a storyboard file) off to make a storyboard for only iPhone or iPad. But "Main Interface" in the target settings can be only one storyboard. So I don't know how to do.
My favorite feature of Xcode 6 so far is the new size classes concept in Interface Builder.
They also enable the condensing of universal apps into one storyboard file.
Combined with the new adaptive view controllers, it's easier then ever to rely on interface builder, rather than fight with it, to simplify the creation of your app layouts. Every view controller in your app gets a trait collection object.
This trait collection object has 2 size classes, a horizontal size class and a vertical size class. And each of these classes has 3 possible values: compact, regular, or any. These values can change based on the device and its orientation.
Your app will layout its interface for each view controller based on the current size classes. Apple uses a grid to let the user choose which configuration to work in, so here's that same grid but with each device+orientation highlighted in its corresponding size class combo.
Kindly refer the Link
I have created new storyboard with auto layout enabled (image below).
The strange thing is the entire view is proportionally stretched. I can't figure out how to leave ratio 1:1. It is not about using auto layout I believe.
The images show the problem:
This image comes from clean app. It shows view on iPhone 6+ simulator. As you see the table cells are 1:1 (smaller then the following example). Also the status bar is fitting with size at the home screen.
This images comes from a new storyboard in existing app. The set up of the story board is exactly the same as in clean app. Moreover the .plist config is matching. As you can notice the cells are bigger, and the status bar is also bigger.
Is this a simulator bug?
I haven't got the device myself, but it was tested on device (6+) and the problem spotted.
What am I missing. Is it auto layout issue?
Ok, I have figured out the issue.
Basically if you face the same problem, just create .xib file for lunch view. Previously it it was image that we needed to add. With iOS8 it is .xib file that needs to be defined in Launch Screen File in General tab.
I was making a user interface using storyboards and when I built my app to see how it would look in the iOS simulator it didn't look like the viewcontroller in the storyboard (some of the buttons were moved around and I had to move one button way down so it was in the place i wanted it to be). Does anyone know why this is?
Yes, the reason is auto layout, it will automatically position elements on a relative basis depending on the device you're running.
You can turn autolayout off, or build for all devices at once and keep it on.
You may want to read iOS Auto Layout Demystified by Erica Sadun which goes in depth to the world of autolayout.