0

I have a View. Inside that view I have Scroll view. Inside that Scroll View I have Content View. I set constraint that content view height and width is equal to View's height and width. The problem is that I have Navigation bar above of my superview. So when I look at simulator on running time it gives me extra space of that navigation bar inside UIScrollview. So have can I adjust height of content view. I want to create constratin like this . Content view height = superview height - 66. 66 is the height of navigation bar...

Yestay Muratov
  • 1,338
  • 2
  • 15
  • 28

1 Answers1

0

the better way is inside your main view put Navigation bar on top of the view and put your Scrollview below the Navigation bar and inside that ScrollView Put the Content View

and if you want to put Navigation bar under the Scrollview you should specify the top space constraint of Content View other wise it will give the same output

Rizwan Shaikh
  • 2,824
  • 2
  • 27
  • 49
  • I cant put navigation bar above main view. I made code that works fine. However it doest work the first time veiw load. I need to press button in order make it work . where should i put constraints of view: here is a code: var heightMinusBar = SuperView.frame.height - 66.0 var constH = NSLayoutConstraint(item: contentViewOfScrollView, attribute: NSLayoutAttribute.Height, relatedBy: NSLayoutRelation.Equal, toItem: nil, attribute: NSLayoutAttribute.NotAnAttribute, multiplier: 1, constant: heightMinusBar) contentViewOfScrollView.addConstraint(constH) – Yestay Muratov Apr 08 '15 at 05:27
  • I put it on viewDidload but it seems not working there. – Yestay Muratov Apr 08 '15 at 05:28
  • just specify constraint of Content View like top space = below navigation bar – Rizwan Shaikh Apr 08 '15 at 05:31
  • in that extra space increase twice – Yestay Muratov Apr 08 '15 at 05:36
  • make sure when you specify constraint the the constraint to margin box is click – Rizwan Shaikh Apr 08 '15 at 05:41
  • the problem: scrollview height = superview.height + navigationbar.height – Yestay Muratov Apr 08 '15 at 05:45
  • check out this question http://stackoverflow.com/questions/18967859/ios7-uiscrollview-offset-in-uinavigationcontroller – Rizwan Shaikh Apr 08 '15 at 05:52
  • refer this it is same as your problem as mention http://stackoverflow.com/questions/1192195/uiscrollview-shifts-below-navigation-and-status-bar – Rizwan Shaikh Apr 08 '15 at 05:57
  • Thanks, Rizwan ! There is now inset now. I just put this code self.automaticallyAdjustsScrollViewInsets = false – Yestay Muratov Apr 08 '15 at 06:19