Q:

Extra 20px Top Inset UIScrollView Issue

Questions regarding this issues has been asked. I tried everything and couldn't fix my problem. I struggled for 2 hours and now i am posting this here.
Issue: UIScrollView's top contentInset has always 20px extra space.
I have viewcontroller xib, not storyboard.
First, related question and its solution on stackoverflow assumes that UIScrollView is the root view of UIViewController. But my scrollview is not root view and hence that why maybe 

self.automaticallyAdjustsScrollViewInsets = NO;

is not working

I have one HeaderView with leadingspace(0, superview), trailing space(0, super view), top space(0, superview)
and fixed height.
Below header view is scrollview with leading space(0, superview),
trailing space(0, superview), bottom space(0, superview) and vertical
space(0, header view)
There is a view inside the scrollview for contents. This view has
leading(0), trailing(0), bottom(0) and top(0) space to scrollview.

Here is the screenshot of that extra 20 px top inset. Extra 20px is the black area between white line and light gray content of UIScrollView I am unable to get this fixed.

Am i doing something wrong? Autolayout constraints seems fine.

A:

Do you have your controller embedded in a navigationController? It seems that iOS is leaving 20px at the top for a status bar but your controller doesn´t have one. 
Either way, in your viewDidLoad it should work if you adjust the scrollView before calling super:
   - (void)viewDidLoad {
    self.automaticallyAdjustsScrollViewInsets = NO;
    self.scrollView.contentInset = UIEdgeInsetsMake(0,0,0,0); 
    [super viewDidLoad];
    }

The reason why iOS might be automatically forcing your scrollView to have a 20px TOP contentInset is because it might be the view with index 0 in your main view. You can read further here: http://b2cloud.com.au/how-to-guides/uiviewcontroller-changes-in-ios7

By default, a UIViewController will automatically adjust the content
  insets of it’s UIScrollView (including UITableViews) at view index 0,
  the very back. This means if there’s a button, label, or any other
  view behind your table view, you wont get this behaviour for free.

