2
votes

I need to set constraints in uiscrollview in viewcontroller containing navigationbar and tabbar.I have placed a uiview(contentView) inside scrollview which is of same height as of scrollview.These are the things which I have set curently,

  1. set 4 constraints for scrollview(top,bottom,left,right) with constraints to margin unchecked which is 0 for all edges.
  2. set 4 constraints for uiview(contentView) inside scrollview(top,bottom,left,right) with constraints to margin unchecked which is 0 for all edges.
  3. set equal width and equal height for scrollview and UIView(contentView)

output is displaying like this uiview(contentView) gets placed lower about 64 px (approx).This view should not place like this.Can anyone help me to solve this.

Here is the project demo which I have worked and can be downloaded here

5
You should read developer.apple.com/library/ios/documentation/WindowsViews/… Particularly Adding a Navigation Controller to a Tab Bar Interface An app that uses a tab bar controller can also use navigation controllers in one or more tabs. When combining these two types of view controller in the same user interface, the tab bar controller always acts as the wrapper for the navigation controllers.beyowulf

5 Answers

2
votes

Select the scene and in the attributes inspector, uncheck: "Under Top Bars" and "Under Bottom Bars".

enter image description here

Then in the storyboard make the scroll view start at the very top of the View Controller, where the navigation bar starts, and then the UIView, where the navigation Bar ends.

Later, select the Scroll View and set the constraints as they come by default.

enter image description here

I guess it's not the cleanest way to do it but I had the same issue and worked for me.

1
votes

You might try self.automaticallyAdjustsScrollViewInsets = false

0
votes

The Tab Bar has to be set in the tree UNDER the scrollView, like this:

controller tree

0
votes

Try this

override func viewDidLoad() {
    self.edgesForExtendedLayout = UIRectEdge()
    self.extendedLayoutIncludesOpaqueBars = false

}

-1
votes

I have found the solution for it,The parent ViewController class is set to under top bar and disabling it and changed the frame accordingly in the parent and set the same property and frame to child viewcontroller fixed the issue.