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.
Related
I want to have a window with a hidden title, as seen in Safari or Xcode, but using a titlebar accessory view instead of a toolbar (I want more control over arrangement and content than a toolbar provides). Is this doable?
I haven't quite been able to make it work. If I set my window's titleVisibility to hidden, and my accessory view's layoutAttribute is bottom, then the title area is empty except for the standard close/minimize/zoom buttons, and my accessory view appears below that.
If I change the layoutAttribute to right, then my accessory view appears to the right of the standard buttons where I want it, but the bottom is cut off because the title bar isn't tall enough, and the view also doesn't resize horizontally with the window.
Is there a way to make this work? Or do I have to use a toolbar?
Update: I used Xcode's visual debugger to examine Xcode's own title bar, and found that it is using a toolbar. The debugger refuses to attach to Safari, so I'm left wondering how it does the new tab button. I imagine that button is a right-pinned accessory view, and the rest is a normal toolbar. Safari's toolbar is still customizable, so that seems most likely.
I decided to go ahead and use a toolbar, and it's working pretty well.
I took my NSTitleBarAccessoryController subclass and made it inherit from NSViewController instead.
I created a non-customizable toolbar for my window, with a single "Image Toolbar Item" in both the allowed and default sets.
The toolbar item has a height of 32 and a max width of 10000 so it can stretch to fill the title bar.
In my toolbar delegate, in toolbarWillAddItem:, I instantiate the view controller from the nib and put its view into the item.
A text label that is effectively the new window title has its value bound to the window's title.
To match the spacing in Xcode's title bar, use a left and right margin of 1 pixel (zero will cut off the edges) and a top margin of 5.
window.titleVisibility = .hidden moves the toolbar into the title area.
I have a problem with a background image in a controller .
I set an image directly from a storyboard with ImageView , but this seems to be disproportionate and grainy on the storyboard , but then when you launch the app screen appears proportionate.
That makes me hard to graphic design because I see the storyboard no depreciation corresponding to reality
What can be ?
I hope I was clear enough
thanks
Go on your storyboard, select one of your view controller
Right panel > Size inspector > Select freeform in simulated size
Put the size you want
Note with autolayout you are designing "responsive" interface, that's why the screen is bigger because it's could be an interface which can fit both an iPad screen or Iphone, also a question of landscape/not-landscape.
I don't recommend to change this mode then, or only if you are building an app for a specific screen only.
Also, by default the layout is set to Any Width / Any Height that's correspond to all layouts possible but you can change this in the bottom of the middle panel.
UIScrollview scroll is not working when i tested application in device (iPhone 5), But scroll is working properly in iPhone 5/5s/6/6 Plus simulator. I am developing application using Xcode 6 and UIStoryboard with AutoLayout.
I set the top, bottom, left and right constraints of UIScrollview with relative to Superview. And i also set the constraints of every UIControl which is in the UIScrollview.
Has any one have solution regarding this issue?
Please see below screenshot for reference.
It's probably easiest to have the scroll view contain a single view, which then contains all of your scrollable content. That single view should be anchored to all 4 sides of the scroll view, and if it's only meant to scroll vertically (which is what your screenshot makes it look like), then set the content view to be the same width as the parent of the scroll view.
To make sure an UIScrollView scroll, you have to check
Size
Your content View is bigger than your Scroll View. If you want it to be scrolled vertically, make sure its higher; horizontally, wider.
Constraints
Make sure your Scroll View is pinned to its super view, Top, Bottom, Leading, Trailing.
Make sure your Content view of Scroll View DOES NOT have CenterY constraint set to Scroll View, cause that'd make content view stuck with Scroll View and it'd never be able to scroll. (That happens to me the last time I was stuck)
Interface Builder settings
Make sure the check in Interface Builder under Scroll View is checked:
Scrolling section, Scrolling Enabled.
I built my project as a Tab Bar Application that utilizes the UITabBarController.
I've set all the auto layout constraints for all my subviews and it looks right in the preview. When my application first starts, I hide the tab bar in viewDidLoad. Once a button is clicked, I hide the view and show the tab bar.
My problem is that the constraints adjusted themselves to the hidden tool bar and everything shifts down the length of the height of the tab bar. If I go to the second tab and back to the first, the constraints are back to normal. Is there an easy way to deal with this? I need to find out how to either hide the tab bar in other way that doesn't compromise my constraints, or how to allow the first view to extend down over the tab bar. Please help.
Hiding tab bar liks so.
[self.tabBarController.tabBar setHidden:YES];
Oddly enough. When I go to set the vertical constraint to the bottom of the view, the distance to the bottom of the view is equal to the top of the tab bar even though the height of the tab bar is 50 px.
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: