UIView not appearing on xib - ios

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.

Related

How to put a UIView in a UITableView and It will be pinned on the bottom

I am trying to build a UITableView Controller, which will be my app's ABOUT information session.
At the bottom of the view, it will be reserved as circle menu. So I need a UIView with height of 200 there, when I drag a UIView to the controller, it always sit as a table cell.
As you can see, the red area always sit under the last table cell group, how to pin it on the bottom of the View Controller.
Thanks in advance.
You can't add a UIView at the bottom of the UITableViewController. If that is a hard requirement you have to switch to UIViewController. And then you can use UITableView and other UIView's as well.
If you are using a navigation controller with UITableViewController then you can use UIToolBar which sticks at the bottom of view controller but have some limitations too. See this
Get UIView controller and put tableview instead of UITableViewController. From side inspector drop UIView out of tqbleview. And in inspector menu for UIView set auto resizing mask for UIView according.

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.

UIImageView not showing on top of MKMapView

In IB, I have added a UIImageView on top of MKMapView(which spans the whole screen above the bottom tab bar). The UIImageView shall represent the map legend.
I have created an IBOutlet for the UIImageView and have synthesized it in the .m file of my mapViewController. I am setting the image programmatically using the following line of code:
[legend setImage:[UIImage imageNamed:#"maplegend.png"]];
I want this image to be there all the time at the bottom right corner of the MKMapView.
But no image is being displayed when I run my project.
Please guide.
I once had the same problem. I solved it by putting the views next to each other instead of over each other in the view hierarchy.
The view hierarchy would then look like this
containerView (UIView)
mapView (MKMapView)
myBanner (UIImageView)
(containerView.subviews == #[mapView, myBanner] in this case)
myBanner can still overlap mapView, because views with a higher index will be placed above views with a lower index.
This would not work:
containerView (UIView)
myBanner (UIImageView)
mapView (MKMapView)
I'm not 100% sure, but I think there is a problem with the MKMapView: it just doesn't want you to put subviews on top of it.
If you also want your legend to be click-throughable (i.e. not accepting touch-events), you would have to create your own UIView subclass for the containerView and override the -hitTest:withEvent: method...

Add UIScrollView to UIViewController

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;

Resources