this is my first job with xCode and I'm migrating an Android App to IOs. I'm attempting to create a ScrollView with some items inside of its content view. Below is a print of the Storyboard tree:
When I run the app, the items below the selected StackView, including it, do not appear correcly on the simulator. They are all overlapped at the top of the screen:
I have already double checked all the constraints, along with other properties on the views but could not find the issue. Any help will be very appreciated.
Thanks!
=========================================
Thanks, Imran. This helped me find the issue. But I still would like to understand it. As you can see from the picture below, some of the views in my storyboard have this "wAny hR" property set. Literally all the stackviews and, the Labels and Buttons which were messy. Once I remove this property and set the "Installed" one, they showed up ok. Any thoughts on that?
After some rearrangement of the views in a view controller in storyboard, the safe area in that specific view controller became bugged. For any device I select the safe area never update its frame width.
In the gif below, I have the Safe Area selected in the document outline to illustrate that.
When run in a device, the safe area works as expected. So this is an Interface Builder specific problem. Doing a Cmd+Shift+K Clean and deleting Derived Data is not working.
So, is there a known method to rescue that view controller other than recreate it in a new one?
I recently had the same issue.
The way I resolved the issue was I selected the "Safe Area" in the storyBoard navigator.
After that I used the restraint controls and choose reset to suggested constraints.
This bug happens if a UIStackView contains at least one multi-line UILabel without an explicit preferred width. I have found no easy workaround that succeeds in all cases.
Here's a tip how to debug these issues: Turn off the "Installed" checkbox on individual views in your scene until the problem goes away. By process of elimination you can identify which control or constraint is causing problems.
I am using old autosizing constraints and want to see live how it will behave like in old days but somehow I don't see this option anymore and it is not autoresizing view when I resize it in editor... So it is not possible anymore ?
Ok maybe I am not too clear... but thats because I thought this is so obvious and used a lot feature of xcode editor...
So I have this on my screen
Before when I dragged corner of view that has size freeform view resized and all view inside resized also according to autosizing layout constraint. Autolayout is disabled in xib. It was possible to turn it on or off in menu Editor > Canvas > Live Autoresizing.. Now there is no such option. Is it possible still somehow ?
So I cam back to my own unanswered question, just accidentally I found that live auto resizing(old style) in editor works, just little but differently. When you change size of view in Size inspector by those up and down buttons, it works like old days...
I'm using a storyboard with some ViewControllers that have elements positioned with autolayout. Every time i open the storyboard, i get misplaced views even after i fix all of them. I have to update the frames time and time again. Is there any way to fix this?
I'm using xcode 6.
As #Anil Varghese pointed out the problem is the size of the view. Anything other than wAny hAny will trigger this warning when opening the storyboard file. I think it's an Xcode bug.
So I had to make sure that my views are set up like in the picture above. This means designing for all sizes, so, in my case, my UI got all messed up and i had to redesign it. But it was for the best!
When you change to wAny hAny you view elements will become invisible because they are bound to other size classes (like wCompact hAny). You need to delete those rules from the Attributes inspector.
I got the same issue, and I also did not know how to fix it completely, but I found this way to make it show what I want.
"Reset to suggested constraints"
then, I set the storyboard back to "w Compact h Regular".
hope it could help you.
Built a new project from scratch in Swift in Xcode 6 (Beta 1) and have seen some strange behaviour with Storyboards and the output that I am viewing.
I have built a simple interface (as shown below) - with properties of View Controller included.
When I run this in the simulator I would expect 'Hello, World' to be central in the user interface - however it seems that this 'Square' is simply being fit into the iPhone screen and thus the wrong view is being shown (see below).
My question is: has anyone else seen this behaviour and how did they fix it?
Thanks!
Do the following steps to resolve the issue
In Storyboard, select any view, then go to the File inspector. Uncheck the "Use Size Classes", you will ask to keep size class data for: iPhone/iPad. And then Click the "Disable Size Classes" button.
Doing this will make the storyboard's view size with selected device.
While Asif Bilal's answer is a simpler solution that doesn't involve Size Classes (which were introduced in iOS 8.) it is strongly recommended you to get used to size classes as they are the future, and you will eventually jump in anyway at some point."
You probably haven't added the layout constraints.
Select your label, tap the layout constraints button on the bottom:
On that menu add width and height (it should NOT be the same as mine) by checking their checkbox and click add constraints. Then Control-drag your label to your main view, and then when you de-click, you should have the options to center horizontally and vertically in container. Add both, and you should be set up.
If you are using Xcode 6 and designing for iOS 8, none of these solutions are correct. To get your iPhone-only views to be sized correctly, don't turn off size classes, don't turn off inferred metrics, and don't set constraints (yet). Instead, use the size class control, which is an easy to miss text button at the bottom of Interface Builder that initially reads "wAny hAny".
Click the button, and choose Compact Width, Regular Height. This resize your views and cover all iPhone portrait orientations.
Apple's docs here: https://developer.apple.com/library/ios/recipes/xcode_help-IB_adaptive_sizes/chapters/SelectingASizeClass.html or search on "Selecting a Size Class in Interface Builder"
In Storyboard, select your ViewController and go to Atribute Inspector. At the very top, under Simulated Metrics you have Size and Orientation properties which are set to Inferred. Change them to desired values.
In order for an application to display properly on another screen size, you also have to setup constraints, as described by Can Poyrazoğlu in the first post.
I had this issue in xcode 6 and there is a way to resolve the resize conflicts. If you select your view, at the bottom you will see an icon that looks like |-Δ-|. If you click on it, you're project will resize for different devices.
Go to Attributes Inspector(right top corner) In the Simulated Metrics, which has Size, Orientation, Status Bar, Top Bar, Bottom Bar properties. For SIZE, change Inferred --> Freeform.
On your storyboard page, go to File Inspector and uncheck 'Use Size Classes'. This should shrink your view controller to regular IPhone size you were familiar with. Note that using 'size classes' will let you design your project across many devices. Once you uncheck this the Xcode will give you a warning dialogue as follows. This should be self-explainatory.
"Disabling size classes will limit this document to storing data for a single device family. The data for the size class best representing the targeted device will be retained, and all other data will be removed. In addition, segues will be converted to their non-adaptive equivalents."
For anyone using XCode 7, it's very easy to design for a specific device size (instead of the default square-ish canvas).
In Interface Builder, select your ViewController or Scene from the left menu. Then under Show the Attributes Inspector, go to the Simulated Metrics, and pick the desired Size from the dropdown menu.
You shall probably use the "Resolve Auto Layout Issues" (bottom right - triangle icon in the storyboard view) to add/reset to suggested constraints (Xcode 6.0.1).