UIView overlaps UISegmentedControl - ios

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.

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.

UIStackView inside a subview programmatically

I've got a ViewController that has a lot of labels that must be displayed horizontally, so I've decided to use UIStackView for this.
These labels belong to different "sections", so I'm using nested stack views to achieve this. The problem is that one of these "sections" should be displayed with a different background color than the others.
I've read in another thread that UIStackView does not have a background color, and I should add the stack view inside a UIView and set a proper background color to it.
What I've made so far:
Create a UIView and set its color
Create a sub stack view and add some labels to it.
Add the sub stack view to the colored UIView
add the colored UIView to the main stack view.
The result: I'm not seeing any of those views inside my view controller.
Note: I need to do this programmatically.
Thanks in advance!!

Hiding labels in iOS without breaking the view

I know we can use UIStackView in iOS9, but I'm not able to get rid of iOS8 at the moment, so I was wondering if is it possible to hide some labels inside a UIView (plain UIView, UIScrollView and UITableViewCell) and keep the rest of the visible labels "stacked".
Basically I've got some labels "stacked" vertically and pinned to each other by autolayout. If I hide any of them I get an empty space where the label was placed in interface builder.
I've managed to emulate the stackView's behavior using OAStackview, Following these steps:
Subclass ViewController using a UIScrollView and a OAStackView property.
Put the stack view inside the scroll view
Set constraints for these properties programatically
Add a bunch of custom labels to the stack view.

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;

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