Xcode Storyboard layout anomaly, bug or something else? - xcode

I"m seeing an anomaly with the storyboard in my project and not sure if it's a bug or something else I'm doing wrong. Within a UIViewController, an element may or may not start shifting its position to the left and down by one each time the project is opened. It doesn't happen everytime the project is opened. It's not limited to any particular type of control. These screenshots of are a UIScrollView, but it happens on UITableView, UITextView, etc.
I'm not using autolayout. I haven't filed a bug report yet.
thanks for anyones help!

If you remove the horizontal and vertical stretchable properties of autoresizing and handle the stretch in subviews then you will be able to fix this bug. I have tried this hack and it was not changing the frame on quitting and re-opening the Xcode.

Related

Weird NSOutlineView crash

I'm experiencing weird crash in NSOutlineView: when i click "collapse" button, app crashes immediately and even "exception breakpoint" doesn't help to see where the problem is.
I've tried to run app without debugger, and reproduced the problem. Once app crashed, i've got OSX crash window and was able to extract crash message from there:
The window has been marked as needing another Update Constraints in Window pass, but it has already had more Update Constraints in Window passes than there are views in the window
there also call stack, but it won't help since crash happening inside libsystem_c.dylib, so i'm not posting it here.
It seems there is something wrong going with auto layout. Absolutely have no idea about next steps. Please give me an advice!
Also, one more thing, that began only after update to OSX Mojave.
After hours of debugging and testing, i noticed that that message is caused by "infinite layout loop".
Different code, related to outline view was causing NSSplitView to layout. And delegate method - (CGFloat) splitView:(NSSplitView*)sender constrainMinCoordinate:(CGFloat)proposedMinimumPosition ofSubviewAt:(NSInteger)dividerIndex has been called about 200 times prior to crash.
It's hard to catch this bcs it's not actually infinite recursion, so just debugger doesnt help a lot.
I just added simple code that helped me to identify the issue:
static int a = 0;
NSLog(#"Layout: %d", a++);
Hope my experience will help somebody else!
For anyone who is having the problem in Xcode 14 and macOS using SwiftUI:
I just had the same crash by hiding a view with an animation. My main view contains two views, one view contained an empty ScrollView, which didn't cause a problem by itself, but by changing it's size it crashed. Just adding a basic Text within the ScrollView solved my problem and the app doesn't crash anymore.
I updated my build to IOS 14 and Mac OS 20.15.6 and the error went away.
try turning off 'Use Auto Layout' checkbox in nib (in File Inspector tab).
May have to disable it for each and every view.
Also, unrelated, but Mojave forces you to use Core Animation.
Most of my nibs have 'set wants layer' turned off.
However, in one of my nibs I had a stray setWantsLayer checkbox checked.
when I unchecked it, the view (NSSearchField) drew properly

How to fix: disabling size classes in Xcode 6.2 trashes storyboard UI but keeps guides

[EDITED] After spending a couple of days on a iPad app (utility s/w for myself; not for release), I accidentally clicked on disabling size classes in Xcode (6.2). I only want to turn off Auto Layout temporarily so I could figure out why my popover scene was not rendering.
Now, all the UI elements are gone but the guidelines for both the main scene and the popover scene are still around. History seemingly shows nothing that will bring back the UI elements. I closed the Xcode project and opened it again, but only the red guidelines are visible.
Has anyone run into this? Any idea how to fix this? [EDIT] I'm referring specifically to the UI elements and getting them all back -- else I'm going to have to spend a couple of hours reconstructing and positioning them. I browsed StackOverflow and Google Search but I've not seen any relevant suggestions.
First, when disabling auto layout it will disable the size classes as well.
I would suggest that you update your Xcode to 6.3. Then that will probably be gone.
Hope that helps :)
Edit
regarding the comment
First off I would print the frames of the UIElements to see whether they are still on the screen. (Using `println("(button.frame)")
Then, if they are not there, change their frames / centres) to somewhere on the screen.
If they are in the bounds, check their sizes to make sure they are large enough to be visible. If they are then make sure they are not hidden and their alpha is 1.
In storyboard you can open the side-bar and then change the element's position in the Attributes inspector as shown here:

Constraints keep going haywire every time I reopen an XCode project

Every time I close and reopen XCode 6 beta 6, my previously-happy constraints are messed up and I have to click on the yellow dot to get to the "Misplaced Views" thingy, then click on each yellow triangle, choose Update Frame, and click Fix Misplacement to correct the problem. Is this a bug in the beta or have I done something wrong, perhaps? Constraints in XCode (to me, at least) are horrible things to tame at the best of times, so maybe it's not a bug?
Once fixed, and XCode neither complains about nor renders the widgets badly, it's fine. But as soon as I close then reopen the project, they're messed up again.
I have experienced the same thing on a project I'm working on. What I've observed is a circular connection among the views in the storyboard in question, so that it's possible to segue around and around a particular path or paths. The views are all embedded in a TabBarController, and each tab has its own NavigationController.
So for instance:
Activity View (programmatically selected tab), segue to ...
Detail View, segue to ...
Profile View (programmatically selected tab), segue to ...
Item View, segue to ...
Detail view
... and so on
This seems to introduce random screwups to the views.
What I have not yet done is test this by removing the circular segue paths. I'm not sure I ever will, since the circular segue paths are part of the functionality of the app. But I'm pretty sure that was about where this weird behavior got introduced. I'll be interested to hear whether the same is true of your project.

Storyboard corrupted

I've experienced a strange problem today. I was working on my iOS app in xamarinstudio. A modification had to be made in one of my viewcontrollers, so i opened up my storyboard to see that most of my viewcontrollers were missing! The connection between viewcontrollers was still there, in fact, my app still works, but most viewcontrollers are missing. When you open the .storyboard file in a texteditor, you can clearly see that the missing viewcontrollers all have their width & height properties set to 0! This happened suddenly, without any warning. I can't even remember exactly when this happened, because i didn't open my storyboard file right away. The only two things i did differently that day is execute the updates for Xamarin studio, mono, xCode, the emulator & iOS and i modified a .xib, so i had to open xCode. Here is a screenshot of what my storyboards looks like now:
Has anybody encountered something similar? And how did you fix it?
Try opening Storyboard as code (2 finger tap) and look around to see if there are any view controllers present. Maybe the size was corrupted to zero? You can edit that inside storyboard.

iOS simulator not displaying labels from storyboard

iPhone simulator is not showing some of the labels properly. Has anyone else experienced this? Does anyone know how to fix it? I also noticed that if I drag the buttons too quickly, xcode would crash randomly...
Thanks
I have come across this issue recently and it was a weird bug. For whatever reason, the x/y axis was off in what I was seeing in Storyboard. So the UILabel and UITextfield I had were being displayed behind my NavigaionBar. I adjusted the x/y values in the size inspector on the right side pane of Xcode and it worked perfectly. Those value should be an accurate representation of the placement of storyboard objects.
Not sure about the quick dragging, sounds like an Xcode issue that may be fixed by now.

Resources