Aligning tableView in specific place of ViewController in Swift - xcode

I am trying to place a tableView in a specific position in ViewController (from half of the page to bottom). But anytime when I am trying to use Constrains the tableView is getting lost somewhere (even if I add Horizontal and Vertical centre in container)
here is the image of my storyboard in assistant editor and view controller scene
and here is a image after adding constrains

Actually I just fixed in the simplest way by just adding missing constrains.

Related

Add Custom Snap-Lines to UIView for Interface Builder

I have always wondered if there is a way to add custom "snap lines" to a UIView descendant, so I have a nice mechanism to layout my views using the Interface Builder of Xcode.
Here is my very basic UIView:
This view serves as a container control for other UIViews. Is there a way to add these lines so Xcode draws the "blue snap" lines when moving a control inside this view?
I know that there are UILayoutGuides but these don't add the desired snap lines to the Interface Builder (Xcode 9.3).
Here is another screenshot:
A workaround for this would be creating a view with a height of 1 and the width of its superview. After that, views with the same superview will snap to it.
Some tips:
Set a light background color for the view, so that it won't be distracting.
Remove the view when it's no longer needed. If you want to keep it for later usage, just hide it.

Auto layout fails in UITableViewCell

My constraints are not working inside a UITableViewCell, although there are no warnings and the layout is working in interface builder if I change between devices and do rotation.
What did I do:
I created a UITableViewCell called SearchResultCell. I want to layout a button on the right hand side and two labels on the left and the labels should horizontally fill the entire space until the button.
Initially, I just placed the views there and - no matter which constraints I defined - in the simulator all views always appeared at the top left corner.
Then I tried embedding them into stack views. The two labels into a vertical stack view which I then put together with the button into a horizontal stack view. Then I defined constraints such that the outmost stack view should fill the entire superview, i.e. I set bottom, trailing, top, and leading constraints to 0.
My constraints
Again, in interface builder it is always shown correctly:
Layout works correctly in interface builder
However, once launched, these constraints do not seem to be applied.
How it looks like in simulator
The only (slight) improvement is that now the button is beside the label thanks to the stack view. But no matter what I try, I cannot get the constraints working inside this UITableViewCell.
What am I doing wrong here? I don't see it.
Did a lot of more digging and finally came across this - indeed, it was my problem as well: Autolayout is ignored in Custom UITableViewCell

UIScrollView cover controllers on top

I have a problem with an old project (Objective-C and No Auto layout).
I am trying to update some logic but I have a problem with a controller.
The structure of the controller is the same as the image attached
I have the problem that when I scroll up the tableView, the scrollView covers the button container view.
How can I solve this issue? I need that the scrollview does not cover that bar.
did you try to have another viewContainer where you put on the tableView and the Line Color?
Basically you need to have something like that:
View
viewContainer (Table View Container)
tableView
Line Color
viewContainer (Button View Container)
button

Superview not resizing with subviews

I have a window into which I horizontally add two subviews. Into each subview, I place a variable number of subviews made up of a vertical slider, a text field rotated 90 degrees and placed to the left of the slider and another textfield, placed just under the slider. The slider subview's constraints are done in code, the parent views are both done in IB. When I add more slider views to the left window than the subview can handle in its default size, it resizes horizontally and forces the window's content view (and window) to also resize horizontally. Great, that's just what I want. But if I add more slider subviews than can fit in the right subview, they just get squeezed together and the subview does not expand as the left. I layout the slider views using code with this category converted to support NSViews, instead of UIVews:
UIView+AutoLayout1: https://github.com/jrturton/UIView-Autolayout
The constraints for the left and right subviews are more or less the same. I can't figure out why the right view does not resize as the left view does.
Here is a link to a sample project that demonstrates the problem:
SliderTest
Some someone help me out with this?
Also, a secondary question as I think my slider view could use a little work:
When a view is rotated using setFrame(Center)Rotation, do the top, right, bottom and top edges remain along the same edges or do they reflect the new orientation of the rotated view?
Thanks
I found the problem. The constraint between the left view and right edge of the window was fixed at 233 instead of >= 233. I had this at some point in the past, as I was adjusting the constraints to achieve the desired behavior and just overlooked this one through the troubleshooting process.

Push segue to scrollview display error

maybe this is a rather simple question. I don't know. I searched the forums for an answer but couldn't find one. I have two views. From a tablecell I push to a second view which contains a scrollview (960 x 455). This scrollview is centered when loaded.
Whenever I push into this view, the left part of the scroll which shouldn't be visible right away shows up for a few seconds. The same happens when I push back. Is there a way to push into the second view and only show the center of the scrollview?
I would have thought that this is occurring because the view is being loaded and then afterwards the position is being set which can take a while when the view is first being loaded as their other things being processed before setting the position.
I am presuming you are using interface builder if so I recommend setting the UIScrollViews visible/hidden property to true in there then in the viewDidLoad method setting it's position to centre after which you can set it to be visible again.

Resources