Add UIScrollView to UIViewController - ios

I am trying to add a UIScrollView to an existing UIViewController (with navigation and tab bar) using storyboard and autolayout but I don't get this to work. Up to now I have added all components to the controller by dragging them on it. Now I try to group them in a UIView, so that I can make this UIView a subview of UIScrollView. When I drag my existing components as a subview of my newly created UIView the position of it is wrong. So I must manually correct all positions. Afterwards the compoents are 64px below their old position.
I just cant get it to work. Is there a tutorial or something how to add an UIScrollView to an existing storyboard?

This is the easiest way to learn how to control a UIScrollViewer within a Storyboard.
http://agilewarrior.wordpress.com/2012/05/18/uiscrollview-examples/

You might want to deselect Ajust Scroll View Insets in interface builder.
You can also set in your viewDidLoad :
self.automaticallyAdjustsScrollViewInsets = NO;

Related

How to resize custom (created in separate file) UIView height on the ViewController which uses it?

I have a custom UIView (consisting of .swift and .xib files). There is a button inside of it which changes its height.
I'm using this custom UIView some of my ViewController. To do it I drag UIView on the ViewController and set its class to my custom UIView. This also allows me to use this button and "change" displayed size of my custom UIView.
However the size of UIView which contains my custom UIView doesn't change and I cannot use GMSMapView which lies under this view.
How can I solve this issue and change actual height of this view in the ViewController too?
The easiest way is to create an outlet of a constraint from storyboard and adjust its constant-property. That will course the view to resize.
Its an unusual behavior that a view resizes itself. The SuperView or ViewController should manage things like that.
When creating an outlet of the constraint, you should consider creating the outlet within the ViewController and not within the view.

UIView overlaps UISegmentedControl

In my app, I want to add a UISegmentControl on top of a UIView.They are siblings of a parent UIView.I pull a UIView to the canvas from object library first, and then pull a UISegmentControl second,but unluckily the first added UIView overlaps the UISegmentControl. What I want is that UISegmentControl is on top of the UIView. I mean UISegmentControl z-index is higher than the UIView.
The following is the screenshot.
One potential solution would be to programmatically send either the UIView to the back or the UISegmentedControl to the front in viewWillAppear(animated:) using parentView.bringSubviewToFront(segmentedControl) or parentView.sendSubviewToBack(otherView). It doesn't solve the issue of the incorrect appearance in your storyboard but it ought to fix the issue once the app is running.
1) First reduce the width and height of the overlapping view to understand its location in view hierarchy. Share your view hierarchy here so we can see in detail.
2) Delete everything from storyboard. Add UIView and then add any subviews. These 2 controls should be children of UIView in view hierarchy.

UIView at bottom UIScrollView does not appear

I'm trying to get an UIScrollView working with my Storyboard. It works but the UIView at the bottom that I use with a gesture tap for getting back is not showing. How can this be?
So everything works expect that. This are the things that I did:
Set freeform in Storyboard
Disable auto layout for the Storyboard nib
Changed the freeform dimensions to X:320 Y:800
Dragged some labels and stuff in the Scrollview
Created an outlet for the ScrollView
Enabled scroll programmatically
Enabled Contentsize CGMakeSize() programmatically;
So I normally did everything, why isn't my UIView showing up at Y:750. The only thing I do with the UIView is setting the Background/CornerRadius.
It would be if your UIView is no included in the calculation for the content size. Other than that I cannot see anything obvious.

How do I add a footer to a UITableView using Storyboard?

Same as this question, only the proposed solution doesn't work for me. When I drag a view to the bottom area of a tableView, it tries to add it to the list of cells higher up:
I'm sure I'm missing something simple... I'm new to storyboards.
EDIT:
Maybe it is adding a "footer" (though, it doesn't label it as such), it's just not adding it low enough. I was ultimately hoping to add an item that would appear at the bottom of the screen (and stick to the bottom of the screen).
TIP: You can use the Tree view (outline view) on the left to arrange the Views (and sub views). I have done a lot of storyboard editing, and dropping things into table views rarely go to the correct hierarchy level in the tree view.
Create a New UIViewController
Insert a UITableView
Resize the tableview by dragging its dimensions
The attached picture has a UITableView on TOP of a UIViewController's UIView. Make sure that you set the delegates in the UIViewController's .m, assign the tableView as a property of the view controller, and then set the tableview's delegate property to the UIViewController object. i.e.: tableView.delegate = self or [tableView setDelegate:self]; also with datasource.
OR you can just click the tableView, on story board, and then drag its delegate and datasource property to THE UIVIEWCONTROLLER! not the view! You can do this by dragging it to the this highlighted part of the view controller's toolbar on the storyboard:
Either you can create a footer view programatically or you can load a view from UIView outlet
UIView *tempFooter=[[UIView alloc]initWithFrame:self.Footerview.frame];
[tempFooter addSubview:self.Footerview];
self.ItemDetailsTable.tableFooterView=tempFooter;
self.Footerview //View outlet
You need to set all the needed constraints of the self.Footerview to get the required layout of the footer view.But you don't need to set constraints for tableview footer itself.

UIView not appearing on xib

I am trying to make a UIView appear as a rounded box on terms and conditions screen as seen here
When I add an UIView to the xib IB the UIView doesn't show up. But if I add a UIButton to the view then I see the view. How can I make the UIView always visible to a specified frame size?
The problem was that I didn't connect the view to the controller.

Resources