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.
Related
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've recently switched up to Xcode 7 Beta 5 and I've been trying to solve the UITableView issue that I know lots have experienced. One solution I found was to disable size classes, however, once I did that I wanted to roll back my solution to a commit I just performed before that.
After I discarded all the changes I was presented with my view controllers and none of their subviews visible in them. In the hierarchy to the left they are listed but are 'greyed out'. Can anyone help with solving this?
Screenshot for reference:
It's worthwhile noting that when the app runs all of the ui elements are still present as expected - just in storyboard they are not displaying.
Try checking it in different layout such as any width compact height.
Grey out generally means that your view are active on a particular layout.
You can see the changes when you tap in the bottom wAny hAny and select different sizes...
I don't have a single clue about this :
I build a simple view in a storyboard (i have buttons, a table view, labels... nothing fancy), and it simply does not match what i get on my device.
For example, the background color of my buttons, or the text they contain. I have no idea why, but since I don't know when (sadly), the storyboard is stuck to a state and no matter what I change, nothing changes when i run it.
Can add views, can't modify anything.
I'm using the wCompact hRegular "style", because it looks like an iPhone( and i'm only building for iPhone), but I also don't understand what that really does and it might be related. When i change this "style", all the views are blank and my outlets are greyed out.
Any help leading in the right direction is most welcome.
OK, first off...
The wCompact hRegular thing is called size classes. And yes, this is that cause of the problem.
You only need to change these when making an app for multiple devices (iPhone, iPad, etc).
If you're making it for iPhone only then don't touch them. Leave them on wAny hAny.
What it does is set certain interfaces/layout for only creating devices.
Unfortunately you have already changed this so the best (easiest) solution might be to delete it all and start again (in the Storyboard) and make sure you set it to wAny hAny.
You can set everything straight if you know what is wrong in the first place. But as you said that you don't know what's wrong thats why I suggest deleting everything.
You can read more about Size Classes in the Apple Documentation.
I'm currently trying to edit a storyboard file, in Xcode 6 (not sure if this is an Xcode bug, or if i've just done something), and when I go to the view i want to edit this is what the scene shows me :
Is this something I've enabled accidentally? or if it's an Xcode problem. It first did this after I enabled source control for the project.
Anyone have an idea on how to fix?
The problem is probably related to Size Classes. If you have the option enabled make sure that the views were created for the size class that you have currently selected in IB (the grid thing).
If you want to make sure it works with any width and height, find the constraint:
and remove it by clicking on the x, leaving only installed checked:
I think Xcode will stop adding these automatically if you set the view to Any Width | Any Height in the Storyboard:
Check that Installed is checked at the bottom of the Attributes Inspector
I just finished an app on iOS 6 and bought a developer account a week ago so haven't had much time playing with the iOS 7 SDK. Just downloaded the Golden Master version and trying to upgrade my app to be compatible with iOS 7.
I received a lot of warnings saying
Misplaced View Frame for "Label - Label" will be different at run time.
and I am unable to run the program. The project contains tableview and its is parsing and displaying XML feed from an RSS.
How to fix this issue?
The accepted answer will fix the problem, but that's not a good solution because it'll remove all your constraints. If you have spent hours on the constraints then don't do that.
If you click the triangle next to the warning you can get the explanation of what is misplaced. Then you can just move the frame to where it's supposed to be. For example:
In this case I just moved my Text View's y position to 94 and the warning will go away. This is because one of my constraints will force the view to be somewhere else when the app is running, but the position is different than where it currently is in the storyboard.
Another way to move the frame to the right position is to click on the warning next to the View Controller name in your storyboard, and then click on the yellow warning sign, and click update frame.
These two methods are not destructive and will not remove your constraints. If anything it'll show that you may need to do minor readjustments in your constraints.
I had the same issue and I get below response form Apple:
You need to update the constraints to match the frames of these views.
I did the following:
Editor -> Resolve Auto-Layout Issues -> Clear all constraints in ** view controller
then I reordered my objects again in the view.
PS: Try Enrico's solution first.
I had the same issue what you need to is , update the constraints or update the frame.
On storyboard you have a small tool bar as shown in below image.
Please see the meaning:-
You can either choose "Update Frames" or "Update Constraints" and Use "Reset to Suggested Constraints".
This will resolve the issue regarding misplaced View.
Don’t drag and drop views to make adjustments to layout. Edit the applicable constraints instead.
Please , let me know if you not clear.
If you are having troubles finding the Update Frames in xCode it can be done like so:
None of the answers work in all cases. As of recent version of Xcode, using a UISearchBar, enabling scoping field enabled in IB makes the search field appear double height (but doesn't show a the scoping bar beneath it). Whether or not you add a height constraint (of any height) to the search field, you'll get the warning that it is a misplaced view that will be 88 H at runtime but is 44 H in IB. Updating the frames (any or all frames) doesn't resolve it. Seems like a bug in IB.