3
votes

I've seen similar questions about custom transitions(iOS7 Custom ViewController transition and Top Layout Guide and Navigation controller top layout guide not honored with custom transition), but I have problem even with regular push. I'm using latest Xcode available now (Version 5.1.1 (5B1008)).

Here is my storyboard: storyboard Problem occurs in 3rd VC

Here is 3rd VC settings: enter image description here

My 3rd controller's layout is follows:

UIView
 UIScrollView
  InnerUIView
    Other views

I've tried two different ways to create a layout:

Ignore top layout guide (it has y = 64 because of nav bar)

I pinned scrollview's top to container (ignoring topLayoutGuide), manually set height of inner view and pinned its top to scrollView. It gave me the following result: enter image description here

Looks fine, but why do I need top layout guide then?

Use topLayout guide

ScrollView's top is pinned to topLayoutGuide. enter image description here

As you can see, top button moved down and view looks strange.

What is the right way of creating such layouts?

2

2 Answers

8
votes

I had the same problem and spent hours pulling my hair out. My container view inside scrollview had weird top offset despite the fact that it had top constraint set. The workaround I've found - you have to uncheck Adjust Scroll View Insets in your controller layout options

enter image description here

that way content view (in my case) stays pinned to scrollview's top.

Unfortunately I couldn't find any reasonable explanation of this behaviour.

1
votes

In my case, Xcode 7 and 8, I had to uncheck the 'Adjust Scroll View Insets' for the Views in my Navigation View Controller. And yes, it wasted too much time before I figured this out.

EDIT: Apple has found out that we have found a solution, so they managed to break this again in XCode 9 and 10, to keep us developers pulling our hair. Haven't found a solution yet.

enter image description here