subview
I'm currently stuck at making this freeform view follow AutoLayout/TraitVariation adjustments, so that it would look the same on every device. The view is contained in a separate .xib file. Somehow, pin and align tools are disabled. How can I refer to Main.storyboard. I wanna know if there's a way of making it follow superview (Main.storyboard) size using Interface builder.
I struggled with the same thing a couple of weeks ago and unfortunately, it seems there is no solution for that. I ended up with coping my XIB view into storyboard :(
Related
I usually create views programmatically. This time, I tried to use Storyboard.
The views in Storyboards cannot be longer than the device Screen. How can I set a scrollview with a content size taller than the device screen in my storyboard?
I also tried to use XIB files instead of a storyboard, but then I didn't manage to link the XIB files to the storyboard.
You can change the simulated size ( you can do it in xib also )
1-
2-
3-
Tip: if your content is too long you can better think of a UITableView
I designed about 40 view controllers using a 5.5 inch storyboard layout. After all of that I tested it on the iPhone 4S...big mistake. everything is jumbled together being for a larger screen size. I was able to fix one view controller up using Size Classes. I am wondering if there is any way I can adjust all 40 at the same time, or at least avoid doing this for every single one. It is really frustrating finding this out now. Thanks!
This is a relatively complicated issue you are attempting to solve, but I have two potential solutions. Both suggestions are based on moving your current interface into containing UIScrollView instances
If you are using storyboards, then for each of your view controller scenes, put a UIScrollView as a descendent of the view controller's view. From there, provided your subviews are contained within other views (like a container view for a set of buttons), you can move those into your scroll view. You will have to setup constraints to define the size of the scroll view's content, but this will allow the size of the device to have a smaller impact on the interface as you will get scrolling as needed.
If you are using nib files (.xib) then it is essentially the same thing, but easier. In this case, move a UIScrollView onto the canvas, but not as a subview of the default view. Once that is out there, move the original view to be a subview of the scroll view and set constraints to be 0 from the subview to the scroll view. Finally, right click drag from the File's Owner icon to the scroll view and set that as the view outlet.
Hopefully one of these will help you.
So i'm learning how to use scrollviews and i've got one working successfully.
When working with an xib file, it's easy to work with a scrollview as I can put a scrollview on the background/ workspace and set the size, how I want my labels and buttons to sit on top of it etc and then when i'm ready, move the whole thing onto my View.
The project i'm currently working on uses storyboards and so I don't have the ability to put the scrollview on the workspace and get my size and arrangement right.
Is there a workaround? What's the best way to do this?
Thanks
You just need to add your scroll view to the view of one of the storyboard view controller's views, and then you can do the same things with it that you could do in a xib file. Also, even if your project uses storyboards, there's no reason that you can't have a xib file as well.
I'm going to explain my situation 1st so that the question is clear. I'm using a scrollview with images in it right now. Those images right now link to different views in a storyboard. Instead what I'd like to do is have that image open up a new UIScrollview w/ views displayed. These views are already in the storyboard of course without nibs.
So I'm essentially trying to display UIViews in a UIScrollView.. except I cant' initialize with nib (at least to my knowledge).
If you are looking for a place to setup your scrollview that is in a Storyboard use awakeFromNib.
I've created a UIViewController with a UIView defined in the loadView method. When I presented the UIViewController's view size in the viewDidAppear: method changed to an enormous size. I will describe the solution in my answer.
First I've created an iPhone project. Then changed it to iPhone/iPad project. And in the MainWindow.xib file the iPhone settings remained. Because of this, the system increased my view's size to a big number. The solution was to create another XIB file named MainWindow~ipad.xib and set the window size properly.
If anybody has any question about this problem, please don't hesitate to ask it.