Xcode auto layout issues on project load - ios

For a while now I have been coming across this strange issue in Xcode where each time I open an iOS project, some of the views in my storyboard (via interface builder) will complain about "Frame for x will be different at run time". I then choose "update frames" and it fixes itself. So far so good, but closing the project and re-opening it will cause the same warnings to show. Could this be a bug in Xcode? Any ideas as to why this change does not persist when reloading the project?
I am currently using the latest version of Xcode (v7.3.1), but this problem dates back to much earlier versions.

This is possibly XCode bug.
I used to face this issue in my previous project.
This is how I got rid of it this time:
Instead of using storyboard sizes like compact Width regular Height, try using Any width Any Height (wAny hAny)

Related

XCode 8.1 Changed Constants in Storyboard Views

When I updated to XCode 8.1, it changed the constants for many of my constraints in my Storyboard and left it in a jumbled mess. I read in another post that the next XCode beta might fix it and am downloading it to try. It's a good sized storyboard and I would prefer not to have to redo all the constraints.
Does anyone know how to fix this issue? Thanks!
Xcode(8.1) has fixed this issues. This was a known issue in Xcode 8.0.
I have not used Xcode 8.2 but if you are facing issues you might want to stick to 8.1. You can refer here as well: -
Layout issues after updating to Xcode 8
Following is taken from Xcode 8.1 release notes:
Interface Builder
New Features
Added Custom Gesture Recognizer to the object library. Use it for custom subclasses of UIGestureRecognizer or NSGestureRecognizer instead of a plain NSObject. This resolves an issue where a combination of stock and custom gesture recognizers on a UIView fails to compile. (27838954)
There is a new Update Frames button at the bottom of the canvas. Click the button to update the frames of the selected objects and their children on the Interface Builder canvas. (27818991)
The Pin button at the bottom of the canvas has been renamed to Add New Constraints. (27819014)
Resolved Issues
Dragging content into static UITableView cell on the canvas works again. (28026179)
Fixed auto layout performance issue with NSStackView using Gravity
Areas distribution. (27910320)
Xcode 8.0 did not always restore view frames from storyboards and xibs when layouts were ambiguous. Xcode 8.1 fixes several of these issues. If you have encountered these issues, resolve the ambiguity in the Auto Layout issues and update frames. Xcode 8.1 will persist them correctly. (28221021, 28244619)
Resolved a layout hang when selecting Landscape orientation in the Device Bar on non-Retina displays when running on OS X 10.11. (27251685)
Xcode Debug Console no longer shows extra logging from system frameworks when debugging applications in the Simulator. (26652255, 27331147)
When using Swift 2.3, creating IBAction connections no longer inserts WithSender in the selector name. (25220368)

The size of UIView/UIImageView on xib(Xcode8) become (1000, 1000)

I use autolayout on xib to create my UI.
When I finish my UI. It work well on simulator.
But when I open Xcode8 next time, the xib show strange.
Some UIView and UIImageView become big.
The size become (1000, 1000)
Even so, when I run on simulator, it look well.
But the xib cannot be modify easily.
I try to update the frame. It become worse
How should I deal with it?
It's Xcode8's issues. And that is fixed in Xcode8.1 beta2.
Xcode 8.0 did not always restore view frames from storyboards and xibs when layouts were
ambiguous. Xcode 8.1 fixes several of these issues. If you have encountered these issues, resolve the
ambiguity in the Auto Layout issues and update frames. Xcode 8.1 will persist them correctly.
(28221021, 28244619)
Details can be found in release notes

Xcode 8.0 layout issue after open storyboard and perform update frames

I developed a project using xcode 7 and i updated my xcode to version 8.0 . According to the below steps it happens (I just wanted to show in which step this layout bug appears).
i opened my previous project and run in xcode 8 it works fine at first without opening the story board from xcode. (This is only a one view of my app).
And i open the story board by selecting iphone SE (new feature of xcode 8)
i ran the project after opening the storyboard, then this view looks fine too but the storyboard view was a mess
(but many other views looks messy in my iphone after opening the storyboard)
storyboard view looks like this
according the the stack overflow researches i perform "update frames" action in storyboard to this view. after that it looks good in storyboard
but it looks wired when run in iphone after perform "update frames"
is this a bug in xcode 8 or any solutions to this. this layout issue starts after opening the storyboard from xcode 8, without that it works fine in UI
you can check this link :https://forums.developer.apple.com/thread/63133 it should help you a little bit , or (I have done this option in my projects) you can change the frame( of ViewController) to freeroam (600, 600) , if your view looks totally different. The final option is to make you constrains again to fit the ViewController's size(the longest but I think that the best option).
Did you put your UI in a subview?
Cause I have the exactly same problem with you,
and I solved the problem by adding " self.layoutIfNeeded() " in the area which generate my subview.
Hope this help.
This issue is resolved by Apple in xcode 8.1 please download the new xcode and try it again running on simulator or device you may get this issue resolved i have done this and it resolve my issue at once while i am now using xcode 8.1.

The issue of Interface Builder in Xcode 8

My storyboards are created in Xcode 7. After I installed Xcode 8, all of them are constantly messed up. When I open one of them, Xcode asks me to select a device (which is a nice new feature). But then it never adjusts views' frames, so I must press "All View: Update Frames" infinite amount of times. And even this doesn't fix all "misplaced" views.
Anybody knows how to fight this problem? Or the only option is to pray that Apple fixes it at some point?
UPDATE 1
It happens every time I open IB, even if I've fixed frames previously.
UPDATE 2
When my colleague fixes same storyboards on his computer, changes stay. No idea what makes my Xcode so special.
I figured out the following workaround
First, set width and height for your view to the values it will calculate on selected device in your storyboard, then preserve superview margins.
This worked for me
Xcode 8.0 has the bug, that it does not save the rects from the storyboard xml-s. So if you fix misplaced views in Xcode 8.0, the problem is gone for as long as the storyboard stays in RAM. When the storyboard is closed and re-read from a file, the issue appears again. (Actually Xcode 7.0 had exactly the same problem in the beginning.)
Xcode 8.1 beta 3 (the most recent version at the time of this writing) fixes this issue:
frames are not 1000x1000, but they stay as they were.

In xcode 6.1, interface builder deleting ui elements

I have a view with some tableviews and some collection views and also some buttons and labels.
I'm not sure if this is new with Xcode 6.1 because I have not worked on the ui aspect of this project for some time. However, when I try to resize just about anything in the view, my tableviews and collection views, and possibly some other elements I am not noticing, get deleted. Specifically, it seems their frame or rect propertied get deleted.
To be clear, this only occurs when I attempt to resize the element by dragging the sides in interface builder. If I resize them by changing the numbers directly either in the IB sidebar or in the xml, this does not happen.
I'm wondering if this is a bug in Xcode or if I have done something to cause this behavior which I can change.
Thanks!
I acheived a fix, at least for this project by turning off auto layout in "show the file inspector" -> "interface builder document"
I have never used this feature in the past so I do not know if it was on in the past but I am wondering if the new Xcode version turns it on by default where the others left it off.
It may also be possible that it has always been on but there is a bug in the feature in the new version.
This fixed the issue for me, at least in this particular project and at least for now. I hope others find this useful.
From here it looks like a bug in Xcode 6.1.
I created a clean project and the behaviour is the same on my machine:
https://github.com/nasht/Xcode6ConstraintTest.git
Resizing one view makes others disappear. Changing a layout constraint from a = to <= or >= also seems to do it.
I've raised a bug with Apple. Suggest you do the same.
workaround: You can install xcode 6.01 and use interface builder from there. You can still compile and run your code using xcode 6.1 if you're relying on xcode 6.1 specific features. (you'll need to rename your xcode.app so you can run both instances. ) It's ugly, but it works.
I found that it's fixed on the next version of xcode (6.1.1)
same problem, yosemit and xocde 6.1. I can resize some view only if i disable autolayout.
I think I ran into this 'problem'. I believe this was because one of the constraints I had was not setup correctly.
What OS X Version are you on? I updated to Yosemite today and 6.1 along with it. When I would resize a label my other elements were not getting deleted but instead getting resized and repositioned. The width / height would change to 0,0 and the x / y would change to 0,0 as well.
I was noticing other issues with Yosemite so went ahead and did a time capsule restore back to Mavericks and Xcode 6.0
I had the same problem in universal app; iphone works fine and the ipad doesnt work.
I'm using xCode 6.1 and OSX Yosemite
My app supports iOS7 and iOS8 and i had the same problem on iOS7 on iPad version only
Fix:
So i fixed it by setting Simulated Metrics in interface builder by
Size = iPad Full Screen and Orientation by Landscape or Portrait
I have got the same kind of problem with Xcode 6.1 and Yosemite :
I have created a view that I have added to the main view, so it appears like a sub view in the View Controller Scene.
Then I resize this subview to 320 x 568. My program works. It corresponds to the program dropit of Stanford CS193P Lecture 9.
I save the project, close it and reopen it : the subview has its width and height set to 0 !
I tried to open the project dropit of Lecture 8 that is quite the same, which was working before (I think in Xcode 6) and same problem ! First I thought that tapping (related to the subview) was not working but found out that tapping was not working because I was tapping on a subview which has its width and height set to 0 !
I have reset the size class wCompact hAny to which all the UIElements are added. and got corrected.

Resources