I find the new auto layout feature in Xcode quite useful. However Xcode always displays the auto layout constraints as blue guide lines. This is sometimes annoying because these guides are displayed at the centers and edges of the views right where also the resize handles are.
So sometimes I can't resize a view by dragging the handles because I just can't grab them. A click will always select the blue constraint guide line. (And I have to resize using the size inspector).
Is there a way to (temporarily) hide these constraint guides?
In the main menu go to:
Editor > Canvas > Show constraints (toggle this to unchecked)
From this menu you can also show/hide layout and bounds rectangles, selection hgihlights and resize knobs.
This is fixed in Xcode 4.5.2
To completely turn the new layout system off, just uncheck "Use Auto Layout" in the File Inspector:
Related
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
I have perhaps a beginner's question but have not found any solutions addressing this specific problem after searching endlessly on stackoverflow and other forums.
My detail view in the storyboard appears to be too zoomed in. At this point, zooming in and out simply zooms in and out on the storyboard, but not the detail view specifically.
Indicators of this are that the alignment arrow to the left of my button is not positioned at half-latitude of the Detail View box, although when I align my button to this marker I do see a crosshair indicating that my button is "centered".
Detail View - Further Out
Upon simulation, it is apparent that using these crosshairs produces a run-time alignment far right and up from being centered. Where my button is currently placed seems to be in the center of the simulator screen but would like my guidelines to allow the button to be centered using the guidelines suggested.
Simulator View
A) How do I "zoom out" within the Detail View so I can see the entire screen in the detail view?
B) How can I center my object if the guidelines are inherently off-center?
Thank you so much for you advice and input.
Are you using constraints to keep the various controls in place etc...?
If not try:
Select all elements in the UI of the detail view. Click on an empty spot somewhere in the View and press CMD + A.
Click on resolve auto layout issues at the bottom right of the Nib editor. (it's the right most icon)
Click on Clear Constraints
Click on resolve auto layout issues again, then Reset to Suggested Constraints
From here, tweak your constraints as per the UI you're working with i.e. iPhone, iPad and whatever orientation it's in etc...
I forgot to mention how I fixed the "too zoomed-in" problem.
In the storyboard controller, on the left navigator panel, within the file inspector, I simply unchecked "Use Size Classes" within the Interface Builder Document section. My view controller changed into a normal iPhone shape and everything finally fit into place.
I have a very simple application.
There is a toolbar on the top, and the bottom.
The bottom toolbar needs to be in a UIScrollView because it's buttons goes off the screen.
But when I test my application on a iPhone 4G, the scrollbar, and it's content, doesn't display.
When I test it on a iPod 5G, everything is where it should be.
I'm not using any coding currently, this is all being done in the storyboard.
Since there is a difference in the screen size of iPhone4G and iPod 5 the UI will resize resulting in the shrinking of all added subviews.
There are two solutions to fix your problem.
1) Add both toolbars. Select the toolbar at the bottom of the screen and in the Editor menu
Editor > Embed In > Scroll View
This will make sure that the UI works out of the box.
2) This is the second way (I am guessing you've created your UI this way)
-> Drag a scroll view
-> Add Tool bar as its sub view.
-> Now we need to set the springs (In our case autolayout attributes.)
The image below will help you understand better
The first constraint "Height Equals" can be added as follows
Editor > Pin > Height
Now Select and edit the leading space to: attribute
and in the drop down menu select "Less than or Equal"
This is similar to setting "UIViewAutoresizingFlexibleTopMargin" as the auto resizing mask.
I'm looking for the following:
I have an object in the .nib file a (box). Whatever happens to the window, resizing, maximizing,... I want the box to be at the same place and have the same width and height at all costs.
How is this possible?
thx!
Since xCode 4.3 I think, objects use auto layout. To disable this, go to the first tab in the inspector. Then uncheck "use autoLayout". Then just go to the layout tab and in the "autorizing" box chek the arrows going from left to right and up to down! Here are some images:
1.
2.
When laying out an NSPanel in IB I usually open a big window space, add and lay out the content elements, then resize the window to fit.
In Xcode 4.4 the items I add always seem to have space constraints associated with them and resize as I resize the enclosing elements and I can't seem to be able to turn this behaviour off.
I've tried setting the constraints to 'less than or equal', but it has no effect. This is insanely irritating, it's as if I need to build my UI from the outside inward, which is crazy.
Any suggestions?
You need to disable the auto layout check-box in attributes for the xib...
I had the same problem but found this on google: http://gentlebytes.com/2011/09/auto-layout-in-lion/