View in simulator has different frame than in View Hierarchy - ios

I have a strange bug where bottom button hides below the screen. The strange thing is that it is actually tappable and in View Hierarchy it displays as it should be. How could this be? How to debug this problem? Frame and constraints are expected and ok.
Sorry I cannot make a simple example to reproduce because I do not know where the problem lies.
XCode 11, iOS 13

I just had a similar experience. Searching around, I found that my view did not have a Safe Area defined (Use Safe Area Layout Guides was not checked in File Inspector). This was an old XIB from prior to Safe Area guides.
After changing this and then adjusting my AutoLayout constraints to reference this rather than the View, things started aligning properly and the View Hierarchy and Simulator matched.
Not sure if this is an absolute answer to your situation, but it solved mine which seems similar.

Related

Changes to storyboard removing all ambiguous="YES" properties

I have a complicated storyboard that has ~20 controllers developed over several years which has been working great. However, with most recent versions of Xcode, each time I make any changes at all to anything in the Storyboard, Xcode goes through and removes ambiguous="YES" in all my controllers. Is there any way to stop Xcode from doing this?
It fully breaks my layouts. Yes, I'd love to go rewrite every controller to not have this issue, but in practical terms these layouts are battle-tested on every device and OS version and that isn't a high value rewrite for me.
sorry to hear you are running into issues with this. Could you provide more information about the storyboard or a view controller sample that is running into layout issues after the change in ambiguous=YES status?
Generally, ambiguity is caused when there are not enough constraints to specify a size or position. For something like an Image View, if an image is specified, then it will have an intrinsic size, and it will be enough to specify just positioning constraints. If ambiguous=YES is disappearing on a re-save, then could there be enough constraints to specify its position and determine its size? Deleting a positional constrain for the given view would put it back into “ambiguous”.
I know this might be too late to answer, but I run into the same issue and I wanted to let a guide to somebody else seeing the same issue in the future.
When a view frame position is ambiguous, the storyboard shows up a warning. Then some subviews include this ambiguous="YES" property in the storyboard file.
That means the view configurations for this Trait is not right. That doesn't mean that layout will not show properly when running the app since we might have Constraints that modify that frame positioning.
I don't know if this is showing up also for constraints ambiguity.

IOS Simulator bug with my view

I want to believe this is a simulator bug, but, can somebody please explain what is going on?
Im running a simple View on my storyboard: (as you can see, the view with green background is my superview). The thing is when I run my app on a simulator (sometimes, not always) my superview doesn't get scaled and I get a black screen!! My view has checked true the Use Autolayout field, cause some things inside need to have constraints.
I can't give constraints to my view because, it's the superview
And yes, I have debugged with the UI and this is the thing, my superview is not resizing.
Okay I solved, for sure is a bug of Xcode. For me was very strange, so, I decided to delete my View Controller and add all my elements again.

Storyboard Safe Area wrong/fixed width for any device

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.

Xcode 7 Beta 5 - All subviews missing from Storyboard

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...

Xcode 6 view controller showing blank screen with autolayout

I'm trying to use view controller that I decided to use auto layout for. Before I used auto layout, the view showed normally like how I intended it to during runtime. But I decided to switch to auto layout (because after all, bigger iPhones are coming), and even after setting it up, getting no issues at all, and seeing that the app scaled well to the iPhone size in IB; I still have a blank screen. To prove it, here are pictures:
So why is this happening? I added the constraints in the square view, and it gracefully scaled to the iPhone view in Interface Builder. If you also look at the sidebar, the alerts for auto layout errors are not present. And IB is rendering everything. But why is the simulator blank?
And yes, I connected all the elements to be code correctly. I verified. And yes, I have code that puts text in a label. Here it is, in the 'viewDidLoad()' method:
override func viewDidLoad() {
super.viewDidLoad()
self.titleLabel.text = "Hello, World!"
}
And I will reemphasise: the app worked before I did auto layout. For this build, I deleted all the elements, relocated them, reconnected them, and added tweaked the view with auto layout unit IB rendered it correctly. But I'm getting different results here.
Please help me. Oh, and sorry for the massive images, I can't figure out how to shrink them.
EDIT: I've gone through and used the view debugger, and tried to capture the view hierarchy to look for clipping or occlusion. Funny enough, the view debugger shows the content properly, and there wasn't any clipping or occlusion that I saw. When I tried to show frames in the simulator though, it didn't show anything. I'm starting to think that this is a simulator bug. Currently, I'm using Xcode 6 beta 6.
I recreated the issue by adding a collection view to a standard view controller and this seems to be the problem:
Having Xcode add suggested constraints gives you this, which causes the view to not show up.
It is aligning the view's left and right to the layout guides (which doesn't seem to be right)
You will have to manually add spacing constraints to your view.
This is what you want:
Try turning on the assistant editor and use Preview while tweaking your constraints.
(source: mattknott.com)
Do your Editing in "wAny hAny For All Layouts Base values" mode. then you will not see blank screen while testing on different devices.
Mode selection can be one from bottom bar.
Good Luck

Resources