How to make UIButton overlapping UIScrollview - ios

I have a scrollview and I need UIbutton/label overlapping it as in example ("Close")
I added UIButton to storyboard above my scrollView and make constraints to the top of the superView:
But the button is still invisible on simulator.

Related

Drag image from ScrollView into UIView

I have a horizontal ScrollView (Height 150) at the top of my UIViewController. The ScrollView contains a number of UIViews (80 x 125), with each UIView containing a 64 x 64 UIImageView.
The issue I am having is dragging the UIImageView into my main UIViewController (UIView Screen).
Whenever I click and drag the image, it is hidden within the ScrollView and cannot be seen.
What am I missing so that I can drag the image out of the ScrollView and into the main UIView screen? So that it is always shown when dragged around the screen.
Thanks
You need to turn of the ScrollViews' clipsToBounds property inside the attributes inspector.

Why does my UITableView need to be below UIButton in the scene outliner

I have an UIView with a UIButton and a UITableView. I constrained the UIButton (left, top, right, bottom) to (0,0,0,-) with a height of 50px. Below i constrained the UITableView (left, top, right, bottom) to (0,0,0,0) so that the screen would be filled with both views as such:
In this case the UIButton is above the UITableView in the scene outliner:
However whenever I reorder the view in the UIView so that the TableView is above the UIButton in the Scene Outliner it also moves my UITableViewCells but not my UITableView:
The constraints are the same and nothing is moved except for the layering in the scene outliner. Why do my UITableViewCells move down whenever i place my UITableView above my UIButton?
Interface Builder does that when "Adjust Scroll View Insets" in view controller attributes is checked.

Stretch UIView in a ContentView of a ScrollView

I have the following problem:
I have a Scrollview with Autolayout top,left,bottom,right is set on 0, in this ScrollView is a ContentView also set everything on 0. The ContentView contains a ImageView a Segmented Control and a UIView which is connected to 2 different UIViewController.
The UIView is set top 0 to the Segmented Control and to bottom 0 to the contentView.
My Problem is that the UIView in the ContentView is not streets to the bottom of the ContentView. How can i solved this Problem?
Picture 1:
Storyboard UIViewController with ScrollView
Picture 2:
View on an iPhone 6 Plus
Here there are the size inspector constraints pictures:
ScrollView
MainView of Controller
ContentView in ScrollView
UIView in ContentView
Seems like the problem is in scroll view bottom content inset. By default scroll view have automaticallyAdjustsScrollViewInsets property enabled, and if you insert scroll view as nearest view to tab bar (as I can see at screenshot), bottom inset will set as nonzero (this used for show content under transparent tab bar while scrolling). But for use this behavior properly, you should connect scroll view bottom to view (root view) bottom, not to bottomLayoutGuide. Second option - disable automaticallyAdjustsScrollViewInsets property and handle contentInset and scrollIndicatorInsets properties of scroll view manually (set them to UIEdgeInsetsZero if you don't want change your constraints).

Auto Layout - UIButton to bottom depending on UI objects in UIView

I have a problem with Auto Layout. In my UIViewController I have the following view hierarchy:
- View
-- Small Bar
-— Scroll View (leading, trailing, bottom to superview, top to Small Bar)
—-— Container View (leading, trailing, bottom and top spaces to superview)
———- UILabel
———- UITextField
———- UILabel
———- UITextField
———- UIButton (full width, top to UITextField, bottom to superview)
I want the UIButton to be always hooked to the bottom of the view, depending on the size of the screen. If, however, after rotating the screen, it will turn out that the button will cover other views, it will have constant about 30 from the last object in the hierarchy.
I've tried with relations between UITextField and UIButton with "Greater Than or Equal" - 20 constant, but it didn't work. I've tried messing with priority, but effect was the same.
Here are the screenshot :
Any ideas?
For making the bottom control to be stayed there always then scroll view should be inside a container view.
Look at this view hierarchy:
-View
---BarView(Leading, trailing and top space to super view, Height)
--=ContainerView(leading, trailing, bottom space to superview, vertical space to BarView)
-----ScrollView(leading, trailing, top, bottom space to super view)
-------UILabel
-------UITextField
-------UILabel
-------UITextField
-------UIButton(leading, trailing to superview(ScrollView), Height, Bottom and Right to ContainerView)
It is working fine as you expected.
Refer this screene
Try it out.

Horizontal dragging of UIScrollView

I have a subclass of UIScrollView class and this scroll have vertical content. But I need drag and drop this UIScrollView in the parent view on horizontal direction. How can I implement this?
You must have a specific hierarchy:
Before you do anything you must go to your StoryBored and deselect the Autolayout option under the FileInspector.
View
ScrollView
ContainerView (if you want one or have one)
View
UIControl (if you have one)
THE CONTENTS OF YOUR VIEW.
You must however make a declaration of the scrollView in your header file:
IBOutlet UIScrollView *yourScrollViewName;
In your main under viewDidLoad:
-(void)viewDidLoad {
yourScrollViewName.translatesAutoresizingMaskIntoConstraints = NO;
[yourScrollViewName setScrollEnabled:YES];
[yourScrollViewName setContentSize:CGSizeMake(320 ,554)]; //320 is the x which is the width. change this to make it horizontal.
//554 is the Height this has to be larger that the screen size in order to have vertical scrolling.
[yourScrollViewName setPagingEnabled:NO];
}

Resources