I am not sure how this happened but the view hierarchy on my Xcode6 project have 'hidden' themselves.
On the menu on the left the views have a weird icon and on the layout view and on the app itself the views do not appear.
On the right side all the constraints are greyed out.
Is this a feature or a bug? i can't really find anything i can click to get them to show again. Did i accidentally hit a shortcut?
I think you have changed the size class in the Xcode. May be you have designed it in one size class(not in wAny hAny)and accidentally changed to another. Only the layout designed in wAny hAny will be available for all devices/orientations. If you chosen any specific size class, your view's and constraint's will be hidden for other layouts(grey out). To get it back change size class at the bottom of the IB to yours(i don't know which one you have chosen initially). I would suggest you to design your layout in wAny hAny and do any specific layout changes for a device/orientation using other size classes.
change it here wAny hAny (Interface builder bottom)
Related
I was designing a storyboard in Xcode. Then I wrote a bit of code. When I came back, all my objects in a view had disappeared. Everything's working I just can't see them on my storyboard. But they appear when I run it. I really need to add a uiimageview to this view. But since there are no objects visible I can't. Any help appreciated and
I think this would be the case with you.
Suppose you add label in controller when size class is any other than wAny hAny. Suppose you are adding label in wCompact hRegular size class.An adding constraint for it.
Now you move to other size class. Suppose you change it to wAny hAny.
Now it looks will not find on storyboard and look like this.
In 4th image label looks like hidden and also not visible on storyboard.
So it is better to design storyboard in wAny hAny to make it visible in all size classes. Assuming this will be the case with you.
Did you add constraints to your views?If yes,you changed the size of top level view,just select views and CMD+Option+=(this is resizing view as suggested). If no,add constraints first. If you drag view with blue lines,this will sometimes work,not always.
Select a size class compact in width like "wCompact hAny"
See the width of size class in red box.
I want to create constraints which simply create a vertical space between two views.
First I create it in the wAny hAny size class with a space of 40.
Then I want to have the same constraint with other values in other size classes.
But when I create the same constraint, just with another value Xcode gives me an
auto-layout error that those constraints are colliding.
Because wAny hAny is valid in all other size-classes as well.
In a first attempt I have deleted the constraint out of the wAny hAny size class but then I get the
auto-layout error that the layout is not defined correctly in wAny hAny.
So, it does not matter how I create it, there is always an auto-layout error. I think I just missed a basic concept here to understand what is going wrong. Can somebody explain it to me?
Thanks.
I have found the problem. I was doing it wrong. What I have done is - changing the size-class by selecting the size-class in IB (clicking on wAny hAny at the bottom of the IB screen) and then just set another constant value. This does not work.
This is how it works. Go to the size inspector and click on the plus sign on the left of the constant. Now add the size class. This creates a second constant for the new size class.
Now setting the value on the second constant does work. The original hAny wAny size class is not affected.
I designed lots of constraints for my iOS app. Now the app works properly on all iPhone in portrait mode. I designed the constraints for the xCompact hRegular class. I realized, unfortunately only now, that all those constraints would be perfect also for all iPad in portrait. So, how can I change the constraints target class without recreating all of them for the more generic wAny hAny class? Thank you.
Select a constraint. In the last property in the attributes inspector, XCode shows you a list of check boxes with the size classes for which the constraint is active. The first check box represents wAny hAny, select it and repeat this for each constraint.
Following is screenshot of my xib :
And this is what appears on simulator :
I don't know why some part of the view is hidden although I have used wAny hAny.
When using auto layout, it's best, in almost every case, to add them yourself, rather than letting the system add them for you -- the system will do that if auto layout is on (Which it is by default) and you don't explicitly add constraints. If you add a view to the canvas, select it, and switch to the size inspector, you will see this message,
The selected views have no constraints. At build time, explicit left,
top, width, and height constraints will be generated for the view.
If you are using wAny hAny, a view that's near the right edge of the view is going to get a constraint to the left side that will be very large, something like 500, so that will be off screen on any phone. You need to add your own constraint to the right side instead.
I am new to iPhone development (I am android developer) so all this interface builder way is really new to me.
I learned the best way to make interface responsive is to build it with constraints. I made few views and put constraints on them and it works as it should on the device, however there is this problem that constraints (as I read) are only applied on the build.
My question is: Can I see constraints in the interface builder (preview). All I see now are guidelines (orange) if something is misplaced. And If I want to move a view, could I just do this by changing the constraint and see the effect in the builder?
You can ask IB to update your views' frames to match the constraints. First, select your view controller or top-level view. Then, go to the menu bar and choose Editor > Resolve Auto Layout Issues > Update Frames. Or use the “Resolve Auto Layout Issues” pop-up in the lower-right corner of the IB pane:
If your layout doesn't turn out the way you want, you can undo (Edit > Undo Update Frames or ⌘Z), modify your constraints, and try again.
Once your frames are in sync with your views, you can edit the constraints in the Size Inspector and IB should immediately update your views to match (if your edited constraints are satisfiable).