Adding a UIScrollView to an existing UIView in Storyboard - ios

I build an app using storyboards and I want to embed one of the view in a UIScrollView. Therefore to do so, I drag an drop the UIScrollView directly in the storyboard. I then adapt it size and position.
After that I select all my items and drag and drop them into the UIScrollView. My problem is that all my items' positions get messed up: they all align in the center of the UIScrollView so I have to reposition them myself.
Is there any way I can keep the same layout?
Thanks a lot for your help!
Cheers

One way is to select the view, then go to editor -> embed in -> scroll view.
For more complex things, temporarily disable autolayout, create a new empty viewcontroller, copy/paste all your subitems there, do your voodoo with your scrollview, paste them back when it's done.

Related

Width and height not adjusting with Xcode Auto Layout

I have created an interface for my app in Storyboard under the Any x Any layout setup, when I run my app the layout is still sized for the square Any x Any and not the phone screen. I want the app to adjust to all sizes and not use a set layout for set screen sizes. How can I do this?
Here are pictures to show my design, and the outcome of running the app.
Storyboard View
Simulator View
The table view is also cut off here
If your ViewController is subclass of UIViewController then add leading, trailing ,top and bottom constraints to UITableView, and contains to your custom navigation bar. or If its subclass of UITableViewController. No need to add any constraints. Just embed your TableViewController into NavigationController.
Hope this will help you
what exactly are you trying to achieve? Your tableview to be entirely on the screen, so not scrollable?
If so, then you should override the layout of your tableview and its corresponding cells. As those cells (and the number of them) define the height of your tableview.
From what I can see it appears that you have manually added a UINavigationBar. I personally find it much easier to embed your view controller into a navigation controller. This will provide you with a navigation bar that will automatically resize depending on the hardware, or size class, of the device. To embed it go to: Editor -> Embed in -> Navigation Controller.
Your TableView seems to be fully in the screen as well? If you have layout issues with your cells not adjusting then I will be more than happy to help you once you clarify what is not quite right.
Hope this helps.
Yep. Been there, done that. Just because something is centered in the Any x Any view in interface builder does not mean it will also be centered e.g. in an iPhone simulator. You always need to make your layout choices explicit with constraints, i.e. in the this case add a "center horizontally in superview" constraint or align the right and left edge with the superview (I really would need to know more about your view controller in interface builder to tell you exactly).
Are you familiar with constraints or should I add some more detail on how to solve this?

UIView with container view not scrolling properly when keyboard appears

I have an issue dealing with a UIContainerView inside a UIView. When I try to show the keyboard to edit one of the fields I would expect the whole UIView (with the UIContainerView inside it) to scroll up and out of the way of the keyboard.
Here is what I see at the moment. Does anybody have any suggestions on how to resolve this issue?
The automatic scrolling for input only happens in things like UITableView. For this one, refer to the Apple guide of managing keyboards.
Essentially, you want to manually scroll up the view when the keyboards appear and put it back when the keyboard is hidden.
Edit: I just realised that you have a
UITableViewController. My guess would be because it's on fullscreen, the table view doesn't have enough room to scroll. In this case, you would need to put the all the views inside a scroll view and follow the guide above.

UITableViewController, Storyboards and UIKeyboard

I am trying to create a UI just like Facebook's comment screen on mobile.
I got a UITableViewController on my storyboard. I need to insert a view docked to the bottom of the screen to place a text field. Since the tableview is taking the full screen, I can't do it on storyboard and I think I need to do it programmatically but how? Should I modify the constraints that stretch the tableview to the edges and insert the views or what?
Thanks.
You can always add table view to normal UIViewController and below it add another view.

How to scroll UITableView in Storyboard editor of Xcode 5?

Storyboard had great feature to design tables of static cells.
Until XCode 5 is was possible to compose long list of cells and scroll the table to edit them.
With XCode 5 the scrolling simple stopped working - instead of scrolling the table, now it scrolls entire the storyboard.
Did anyone solved this problem?
I'm completely stuck with my long tables of static cells...
In the storyboard view uncheck Under Top Bars with the problematic scroll view selected.
This allowed me to scroll all the way down.
This only occurred in one of my views, so still not sure what it happens.
I just tried it in my XCode 5. After selecting one of the other not covered table cells I am able to scroll down to the other hidden table cells. Does this work for you too?
Similar post, maybe this helps you too:
Can't scroll to the bottom of a long Static TableViewController in XCode 5 Interface Builder to edit the cells below the fold
Here are the steps that I have found to work:
Select the TableViewController in the Document Outline (view to the
left of the Storyboard).
Click on the Status Bar (or somewhere along the top) of the
TableViewController so that the entire TableViewController is
selected in the Storyboard View.
Use the scroll wheel on your mouse or the "2-finger scroll" on the
trackpad.
The scroll bars on the side of the Storyboard View only seem to move the storyboard around.
It also only seems to work if the mouse pointer is hovering over the TableViewController.
Using Xcode 5.0.2 (5A3005)

Rearrange UIView Subviews if a Subview is removed in Auto Layout

I am in a need of implementing a drag and drop controller in Full-Auto Layout environment.
I have achieved the dragging and dropping successfully, but the issue is if I drag a subview from another view the other related subviews behave weirdly,
as an example the subviews are laid out horizontally in scrollview are related to each other, so if I remove a subview the other views should rearrange them self automatically.
Regards,
Dhanesh.
when you doing the design part of xib uncheck the autolayout.
After completing the designing then go towards to autolayout and arrange the view using constraint adding.

Resources