UIScrollView in NavigationController ignores top layout guide - ios

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:
Problem occurs in 3rd VC
Here is 3rd VC settings:
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:
Looks fine, but why do I need top layout guide then?
Use topLayout guide
ScrollView's top is pinned to topLayoutGuide.
As you can see, top button moved down and view looks strange.
What is the right way of creating such layouts?

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
that way content view (in my case) stays pinned to scrollview's top.
Unfortunately I couldn't find any reasonable explanation of this behaviour.

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.

Related

UIViews inside a super or master UIView, display correctly in StoryBoard but shrink in the emulator

I am quite new in swift programming and I am developing an app which has multiple custom views, hope some one can help me here.
The issue is that I have a scrollView, inside I have a stackView with about 20 Views inside, every view has inferred constraints and every view has a fixed height, maybe not the best practice but most of the views show correctly (had to re-do about 3 times to get here), but one of my views (around the middle of the stack) is showing correctly in my story board, but somehow it's shrinking it's subviews when launching the app, not sure if I am missing something, I have even removed all the content of these subviews and left only the main views with their heights but still I have the same issue.
To be more detailed the section that fails is a view inside the vertical stackView, it contains a view (container) which has the same leading, trailing, top and bottom as the first one. This container view, contains 5 (sub)views which have the same height each (124), and have practically the same content: a label, a texfield and a custom slider (thought the slider was ruining everything because it's custom but after removing all from the design the error still occurs).
Here is an image of how it's shown in the story board:
views in story board
And here is how it's displayed in the emulator:
view in emulator
Does anybody now why can this be happening? I am not doing any layout stuff in the code only a couple of corner rounding in other views that are inside the stack view.
BTW, I also implemented this 5 slider views using a vertical stack and had the same issue, I switched and changed to simple views and separated by 10 each bottom with the next view top.
Thanks

iOS - Top Layout Guide height issues

I am refactoring some views in my application regarding iPhone X constraints and moved a group of views into a TabBarController view with also a Navigation views. Everything working just fine but one thing. Well... There is always that "one issue left" thing, isn't?
So the issue that I have is that the Top Layout Guide is set high. And I don't want that. See screenshot about this issue.
I have set the top constraint of the labels "Maandag" and "Op afspraak" (top one) to 0. Well to the Top Layout Guide. All views that I converted to this TabBar view has this issue :( I am using Storyboards.
This is the result on device (same on all kind of devices)
Thanks in advance!
With iOS 11, Apple is deprecating top(bottom)LayoutGuide and switching to the safeAreaLayoutGuide. In code, you could pin your view using view.safeAreaLayoutGuide.topAnchor, but in storyboards you'll want to pin stuff to the safe area node inside your view controller's view:

UIScrollView gets created at wrong position for first time

I'm trying to create a scroll view which goes behind of navigation controlled but when the view controller is viewed at the first time scrollview gets created below UINavigation Bar if you scroll it gives a leg and gets adjusted and works fine. I check everything but I didn't found the problem I think it's a Bug
It's Little bit difficult to notice in GIF. I Have Attached a project creating that problem just have a look at it. It's attached below
LINK TO PROJECT
The problem can be solved unchecking Adjust Scroll View Insets as shown below. This stops your scroll view from ignoring you auto layout constraints and stops it from adjusting its bounds from your navigation bar.

UITableView leaving gap below transparent UINavigationBar (within single UIView on UIViewController)

I am working on a Swift iOS8/9 project and using Xcode 7, with storyboard / autolayout, etc. (For completeness: I started at the beginning on the year on older versions of Xcode, etc.)
I have a a UINavigationController hierarchy and some View Controllers contain a single UIView which contain a single child, a UITableView. (I am choosing not to use UITableViewController, so suffice to say ... it is not an option.)
The problem: The tableview starts 64 pixels (status plus nav height) too low:
Now: I've had things working for some of my UIViewControllers containing a UICollectionView within a UIView but I achieved it (after lots of poking / prodding, and a while back) by a top alignment constraint from the top of the UICollectionView to the top of the Top Layout Guide. (Looking through my storyboard I some alignments and some vertical distances, but all to top of Top Layout Guide.)
I am looking for help understanding if I can do what I want, if the approach of constraining the top of the tableview to the top of the layout guide is correct, or if there is a better way.
Unfortunately, I cannot seem to repeat this (perhaps 'cos I've forgotten some key press combination jujitsu, or new Xcode, or collection != table, or something in my view hierarchy. (I've checked all segues are adaptive push, I've even deleted/re-built this VC since I had one model segue, just in case it was confused that this VC isn't in a navigation view controller hierarchy.)
If I control/drag to connect or select the two to align:
this is what I am offered - note no "align to top":
Note: Here are the table settings that (to my understanding) should be adjusting edge inset and scroll offsets correctly, and do appear to ('cos it is the only child of the top view, per documentation.)
Here are the frames after view did layout subviews:
The approach that I ended up using came to me when I spoke to #ProgrammingBonn and mentioned the frames. I saw that the primary UIView was position as I wanted, and so it (finally) dawned on me to align the top of UITableView to the top of the UIView.
(I suspect that much as I was building my own ViewController and not relying upon UITableViewController I had an over inflated view of this particular view within the hierarchy. It was a subview not a primary view, despite occupying all the screen real-estate.)
So, to be clear:
I selected the UITableView, then command/selected the UIView (the main one, and it's parent) and then used the "align" tool to top align those two.
Try unchecking the "Adjust Scroll View Insets" option.
I am not sure whether this will fix your problem but have you tried playing around with viewController.edgesForExtendedLayout?
See more info here:
Explaining difference between automaticallyAdjustsScrollViewInsets, extendedLayoutIncludesOpaqueBars, edgesForExtendedLayout in iOS7

scroll views working fine in iOS 7 with problems in iOS6

I hate iOS scroll views with auto layout, they are driving me crazy!:-D
I have found a method which works perfectly on iOS 7 to use scroll views:
I put the scroll view directly in the main view, attaching the scroll view to the edges of the super view(top,bottom leading and trailing space equals to 0).
Then I put a UIView into the scroll view attached to the edges of the scroll view, (top,bottom leading and trailing space equals to 0).
Then I set the height constraint of the most internal view, I link it at my ViewController class, and I modify its value programmatically.
Or, if the view it's 'static' I put every component using the storyboard into the internal UIView, starting with the one at the Top attached to the top of the super view, the one under, attached with the constraint 'Vertical Spacing' referred to the one over him..and so on... Until the last, which is also attached to the bottom of the UIView..
Everything works fine in iOS 7, it's perfect, but iOS 6 is messing around with the constraint.
When I first launch the view everything is perfect, but it seems to recalculate the constraints even on the didappear(and in a bad way), in fact, if I leave my view while it's scrolled down, when I come back to it(let's say we are in a navigation controller) , is like it's everything 'moved up' and the components at the top are hidden.
Is there a way to make scroll views work in both iOS 6 and iOS 7, I'n thinking at two storyboards as the only solution, please tell me there is another way... :-)
thanks everyone, I post two images explaining my problem, taken from the top of the screen:
Well uncheck use AutoLayout in file inspector and try.

Resources