One of the screens in my app has to be vertically scrollable. Its contents is more or less static, but it doesn't fit on the phone's screen (hence the scroll view). I'm using a UIScrollController as a top view, and I'd like to use the storyboard editor in Xcode to lay out all the views in it. Can I do that? I can obviously drop things on the visible part of my UIScrollController, but can I put more views "below the fold" visually?
There is another way to do it that is different from the answers given in the link in the comment above which I believe is easier because it allows you to see your whole content view at full size and design it in Storyboard.
1)Place a UIScrollView as the root view of the controller.
2) Click on the View Controller in storyboard and goto the
Attribute Inspector and change the Size to Freeform
3) Click on the Scroll View in storyboard and goto the Size
Inspector and change the Width & Height to as big as you need.
(2,000 x 4,000)
4)Place a UIView as a subview of the scrollview, this will be your
Content View where you will design your screen and put all your
subviews. Don't forget to set the contentSize of the scrollview to
the size of this view in viewDidLoad.
5) Click on the UIView from #4 and in the Size Inspector set the Struts and Springs so
this view is not resized .
6) Design the rest of the screen
The trick is in #3 & #5 setting the size of the scrollView to really large so you can design. When this viewController is loaded into the iPhone the Struts & Springs will resize the scrollView to the size of the iPhone screen, but the contentView will stay large.
It's possible finally in Xcode 11!
Select some view inside your scroll view in the View Tree and then scroll with your touchpad/mouse:
Related
When I maximize my window, I want to restrict a vertical layout (and the entire row below it also) so that it has a specific size (lets say a width of 200). How can I achieve this? Below is what I get now. The buttons are stretched too far. I want them to keep a width of 200.
To stop the buttons stretching, use the following steps in Qt Designer:
click on scrollArea in the Object Inspector
click on Break Layout on the toolbar
click on scrollArea in the Object Inspector
click on Lay Out in a Grid on the toolbar
click on scrollAreaWidgetContents in the Object Inspector
scroll down to the bottom of the Property Editor
change layoutColumnStretch to 0,1
These steps should remove an empty column from the scroll-area grid-layout, and make the second column stretch to take up the available space when the window is resized.
You just need to restrict the maximum width of all widgets (in this case the buttons) within the layouts of this grid column to the expected size, else they'll just keep expanding. You may also have to fiddle the horizontal size policy; I seem to remember that buttons were a bit tricky in this regard (or was that the height?), but can't test it right now.
The layout size contraint you tried only applies to the layout's direct parent widget, if it has one, which isn't the case for the vertical layouts here.
I have noticed that in the simulator using iPhone X, the tabBar increases dimension vertically to respect the safe area on the bottom of the screen. However toolbars added in storyboard do not and still maintain their default 44 height which causes the toolbarItems to be cutoff on the edges.
How would I duplicate the tabBar behavior for the toolbar on iPhone X without customizing the toolbar?
In order to be able to constrain items to the safe area in a storyboard, you need to enable "Use Safe Area Layout Guides" on the storyboard, in the Interface Builder Document section:
Once you've done that, you can, as mentioned in the other answer, constrain to the Safe Area:
The solution is to change the vertical constraint in storyboard on the bottom and sides to the safe area rather than container margin:
I am writing an application where I need to move a view from top to bottom but only when user moves it downward. To move this view I have a button below the view to drag. So initially I place the view beyond top of the view i.e. with negative margin equals the height and only the drag button is visible at the top to user. I see that this works perfectly on Lollipop and view is just at the position where bottom of view matches the top of screen. When I try it on Kitkat and lower versions, the view goes more towards top than the edge of screen. I have this everything in a RelativeLayout.
To show that view is dragged downward I am manipulating bottomMargin and topMargin properties on view.
Has anyone came across similar problems? Thanks in advance.
Scrollview in Xcode6 is ridiculing me a bit.
I have added a scrollview, and a content view inside the scroll view.
The content view has some various sub views.
My problem is with the new layout in Xcode where it's the w Any by h Any - adaptive layout or what they call it.
The problem is that the content view is suddenly 600 pixels wide so I get some horizontally scrolling, which I do not want.
I simply want the content view's size to be as wide as the device.
Ahh - I found the answer. Simply add a constraint making the scroll view and content view the same width.
I have a DevExpress LayoutControl set inside a WinForms Form. I would like the LayoutControl to resize horizontally when the form is resized, or at least make the LayoutControl resizable by the user.
I have seen on DevExpress's page suggestions to change the SizeConstraintsType property to "default". I have also tried to anchor the control to the right and left of its parent. I have worked on increasing the MaxSize, also. Does anyone know how to do this?
I just basically want to do the equivalent to (in HTML) <table width=100%>. Does anyone know how to do this?
Thanks in advance!
The Developer's Express LayoutControl is a very nice tool, but has a couple gotchas.
The LayoutControl itself should resize just fine docked inside any container control like a form, a user control or a panel control. In many cases the layout control is one of the first things you put on your form/control because everything else goes inside it to be "layedout". So you should set the "Dock" property of the layout control to "Fill" or to the desired edge of the form/control you want it to dock to.
The "gotcha" here is that layout control's internal logic may limit its external dimensions or any internal item if it is capable of doing so and the layout items want to be a particular size. This is actually simpler than it sounds.
For example lets say you have a label control inside your layout control. A label control by default will size itself to fit the width of its text. In turn the layout control will try to accommodate the label's desired size by shrinking/growing the size of the layout item. So this one label control could be messing with your layout controls resizing. I chose label as the example because it is the most common control to mess up your layout design.
The way I fix this is to change the label's "AutoSizeMode" property to "vertical" (if you want text wrapping) or "none" (if you want to force it be the size the layout control wants it to be). This free up the layout control to make the width decisions.
Also if you are allowing the layout control to be resized by the end user (say with DevExpress' SplitterControl) the layout will again try to become its optimal size and not allow the SplitterControl to move away from this optimal size if the other controls are more easily resized (like a grid, tree, list, etc...). In this case adding an "EmptySpaceItem" to the layout control will allow it to fill any empty space when being resized. To add an EmptySpaceItem to your layout, right click the layout control in the Visual Studio designer and select "Customize Layout". The customize dialog will have a list of items you can drag onto the layout control including the EmptySpaceItem.