Xcode 8.2 Interface Builder Update Frame & Constraint Issue - ios

I recently updated from Xcode 7.3 to 8.2. I was using autolayouts and size classes in Interface Builder in 7.3 and everything worked fine. Now in 8.2 the IB preview doesn't correctly represent the positions of the views. However when I run it on a device or a simulator it looks fine. But if I update frames or update constraints in the preview everything gets jumbled up.
Is there anything I can do to stop update frames or update constraints mucking everything up?

Near the Stack button, there is a new "Update frame" button, its just left to the stack button

I worked out what the problem was. There was nothing wrong with the constraints I had. The issue was that in Xcode 7 the storyboard was in ipad size. Initially when I loaded the project in Xcode 8, it opened to view as iphone 7 plus size. When I changed the storyboard to view as ipad pro size and updated frames it fixed everything. And then when I changed to view as iphone 7 plus size it resized everything perfectly as it should have done in the first place.

Related

Why my Xcode interface builder show red block and failed to render

Problem
I have a Controller in Storyboard which has a long UIScrollView inside. Previously it shows perfectly in Interface Builder and now I haven't changed the code. The last time I knew that I updated Xcode to version 11.0. I don't quite know why it fails to render, is it some issue in Xcode 11?
If I compiled, it's success with 0 error and some warning (Which seems me to some Swift deprecated). Even it shows perfectly in Compiled App. I have tried:
Clean Build
Delete Derived Data
Reopen Xcode
Rebuild
Restart OS
Edited after some experiment
Okay, so I tried a bunch of things again and I think I narrowed some problem (maybe?). So my layout show perfectly in iPhone 11 preview, but it fail to render in iPhone 11 Pro Max, iPhone 11 Pro and iPhone 8 Plus preview. Is it ringing any bell?
iPhone 11 screenshot:
iPhone 11 Pro Max screenshot:
iPhone 8 Plus screenshot:
Obviously a change in storyboard previews in Xcode. Seems like it's no longer acceptable to show "simulated size: freeform" greater than iPhone screen height. Changing it to "simulated size: fixed" in Size Inspector solves the issue, and you can now scroll from within the reduced size window in storyboards view...

Xcode 8.2 & 8.1 crashes when enlarging any view in storyboard

When I click on a view frame and drag to enlarge the view, the view is not getting enlarged . But instead the mouse waiting indicator would come for a second and then the whole xcode will crash.
This was happening after my code 8.2 update. So I tried installing xcode 8.1 and the issue is still there for one particular project. All other projects are working fine. There are no warnings or conflicts in the storyboard. I don't remember changing any settings as well.
Attaching the crash log: CRASH_LOG
Fixed the issue:
The issue started after I added a ScrollView to a ViewController and changed the simulated size of the ViewController to fit the scrollview content. I changed the simulated size to freeform and the issue started to appear. I changed it back to fixed and now everything is working normal.
But I hope it shouldn't be happening and apple will fix this soon.

XCode 8 XIB Autoresizing issue

I have older code, written for iOS 6. I need to implement it for iOS 10 with some new SDK. I have some XIB's. Everything was working perfectly when I was changing them. But in one XIB, when I try to change Image in my Interface Builder of UIImageView, whole layout just collapses. I have 2 views, called TopBar and Content. When I try to change just background image of TobBar View, Content view just collapses, actually, TableView in Content View just goes off the screen on the right and you can scroll to right to see content of a cell. Everything is shifting in my Content View to the right. In my XIB, image view is shifted, TableView is so big to the right. When I place everything as it was, sam thing is happening after build. I have been reading for some time now, and changing from XCode 8 to XCode 7.x in my IB does not work, layoutIfNeeded does not work. Does anyone knows what's the problem? Code still uses Autoresizing masks.
Anyone in same situation as me: in XCode 7 it is working. So, I draw in XCode 7, and build in XCode 8, but I need to build for like 8 times, when it fixes itself. I have reported a bug to Apple.

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