Xcode 8 attribute "hidden" does not hide view in Interface Builder - xcode

seems like Apple change how Interface Builder behaves in Xcode 8? Because when I check hidden in Attributes Inspector on a view in Interface Builder, that view is still visible.
This makes it very tedious to work with views where some views needs to be the view with the highest "z value", the front most view that is.
Is there some other way to show the green view in this example, than to change the order of them to the right (i.e. change their "z value")
In the image below hidden is checked, but I still don't see the green view below. You can download this trivial project at github
When the project is run, the green view is indeed shown, but the issues is that it is annoying when working in Interface Builder.
Am I missing something?

I have the same opinion on it and I also believe that it's annoying. I with they gave you the choice to update the actual storyboard before runtime or not but they didn't so for now we have to deal with it.
There is a quick alternative option though. Hidden will not update in the storyboard but alpha will. If you change the alpha it will update in the storyboard so if you want to see the view behind it just change alpha to 0. You can always change it back easily or if your doing it in code, instead of unhiding your view just change the code so the alpha is set to 1.

How about unchecking the installed checkbox of the red view?
This has also the flaw that you have to remember to reinstall it, but you don't have to change the z-order of your views.

This is deliberate. We wouldn't want a view to be hidden from you, the editor, just because it will be hidden when the app runs. You can easily select a covered view, such as the green view, using Shift-Control-Click on the red view (or use the document outline at the left of your screen shot).

Related

Silence "Views without any layout constraints may clip their content" on a specific view controller that has preferredContentSize set

I have a view controller that's fixed size (it can not be resized). This specific view controller is presented as a sheet in a window, I disabled the resizing by setting preferredContentSize. Since it can't be resized anymore, I left the view without any constraint. However, when I build the app, I got a lot of warnings that says :
Views without any layout constraints may clip their content or overlap other views.
I do know that if you don't add any constraints in a standard window it will clip when it is resized. However, resizing is disabled on my specific window so that I know it won't happen. Is there a way to silence this warning? There are a lot of views on this specific view controller and it's blocking other useful warnings that I may encounter in the issues navigator.
This view controller is presented through a "Sheet" segue.
I had a single warning saying the same thing.
Editor > Resolve Auto Layout Issues > Add Missing Constraints
worked for me.
If it doesn't for you, something else under "Resolve Auto Layout Issues" might work.
For me what worked was the reposition the elements: Drag them again into position and drag their height and width to the desired size again. Then click on "Resolve Auto Layout Issues" and click on "Reset to Suggested Constraints".
Since no one answered this, here is how I fixed it. For each view on the form change the Layout option from Automatic to "Translates Mask Into Contraints". If you want it anchored to the upper left corner, select the top an left red handles and leave the lower and right unchecked.
For me what worked was; select the last element that cause the warning
size inspector tab > layout > Autoresizing Mask

NSToolbarItem and Auto Layout

I have a window with a programmatically created toolbar, which is populated with an NSToolbarItem that has a custom view defined in a xib file. If I check "Translate Masks into Contraints" for the view, then it doesn't resize itself correctly, so its content gets squashed even though I set its compression resistance priority to 750. If I uncheck that on the other hand, then I get a "Detected missing constraints" error at runtime. Also, the content of my view then resizes itself correctly, but it ends up clipped like so:
So it looks like the toolbar sticks my view into a container view and, in order to get the correct behaviour, I should set up layout constraints that allow my view to position itself correctly. However, I don't see how to access that container view... Any idea what I am doing wrong?
I am probably missing something obvious since one would think that this is a very standard setup, but Google didn't come up with anything.
Answering my own question, I opened a support request with Apple, the outcome of which is that this is now being treated as a bug by Apple.
In case anyone else runs into this, a good workaround is to create an intermediate view which contains the toolbar view as a subview with constraints #"H:|[toolbarView]" and #"V:|[toolbarView]", has translatesAutoresizingMaskIntoConstraints=YES and to use this view as the toolbar item. It then suffices to listen for size change notifications of toolbarView and to adjust the size of its superview accordingly.

"View As" option in Interface Builder stuck in one view

I have multiple view controllers for my app and I've been working on one view at a time in Interface Builder to make sure they work on all screen variations. I used "View As" option quite frequently to see how UI looks in different screen sizes. I just finished working on one view controller and want to move onto another view to do the same. However, the "View As" option does not change the screen size of the new view which I have currently selected. Instead, it changes the screen size of the view controller that I worked previously. This option seems stuck with the first view controller. Is that a bug or I'm doing wrong?
Just in case if anybody runs into the same problem, here what I was doing wrong. I need to set Simulation Size value of the viewcontroller that I want to work on to "Fixed" instead of "Freeform". Otherwise, it won't work.

Labels in XCode View, positioned differently in Simulator?

In XCode 7, on a Swift 2 project, when I place a label onto the View, why is the label centred in XCode, but in the Simulator it's show off to the right?
This is just playing at the moment, where I don't want to play with constraints just yet (which I believe will be used later).
I had the same problem when working through a demo, and this worked for me. Try using the 4.7 inch size view controller:
Look in the middle left hand menu (the Document Outline), if not shown it’s under Editor > Hide Document Outline (a misnomer, clicking it will Show or Hide it).
Click on the View Controller so it's highlighted.
Click on the 4th tab of the right hand one (Utilities: the Attributes Inspector). If not shown it’s under View > Utilities > Show Attributes Inspector.
Under Simulated Metrics is a Size option to change from “Inferred” to “iPhone 4.7-inch”.
You'll need to realign things again, but now these should look central in the View and in the Simulator.
Constraints, when you want to get to them, will probably be more helpful in this regard.

IOS/Xcode: storyboard screen turning black

I am just learning Xcode. I did something that caused a view controller to turn black below the navigation bar when you build app.
It looks white in storyboard.
Also, when I pull a label onto the storyboard, it aligns to the left margin and does not show the drag boxes around it.
I may have inadvertently clicked something but when I compared it in attributes and identity inspectors line by line to another project, nothing seems amiss, i.e. everything is the default value.
Has anyone run across this?
There is not code in associated class that would cause this as it is generic i.e. plain vanilla.
Would appreciate any suggestions. Thx.
With that little information i'd say you removed the root view of the controller?
Either way, you say there is no code, so I'd suggest you simply delete that controller and create another one (bottom right, objects, viewcontroller). Since it's empty you're not gonna lose any data or time :)
Then link it to your class in the Identity Inspector and you're good to go as if it was a new one.

Resources