iOS7 Content Offset by 20 pixels for non existent Status Bars
Asked Answered
S

2

16

I have a strange behaviour with my UIViews as I'm migrating to iOS7. It seems that they are sent a message to shrink by 20 pixels. I have removed the status bar from all my XIB files and explicitly set it to hidden in the application delegate. My UINavigationController seem to be sent a message:

_computeAndApplyScrollContentInsetDeltaForViewController

which in turn sends messages to my scroll views

_adjustContentOffsetIfNecessary

which set their offset to -20 pixels... This should not really happen as there is no reason for that function to adjust anything by that amount.

Does anyone have an idea of how to fix this?

Saltzman answered 12/9, 2013 at 17:23 Comment(0)
S
77

I found the solution! Just set:

self.automaticallyAdjustsScrollViewInsets = NO;

on the view controller that has the scroll view as a view...

Saltzman answered 13/9, 2013 at 13:49 Comment(1)
Really appreciable and simple answer... Thanks a lot @Mike M.Beating
G
0

20 pixels (or maybe points) that sounds like its the status bar when its NOT receiving a phone call (I believe 40 when receiving a call). Not sure if this will fix your problem, but I had an issue where in iOS7 my status bar was not being hidden. I hid it programmatically and it still displayed in iOS7, but when ran in iOS6 the status bar would hide appropriately. You have to go to the plist and add the following: 'view controller-based status bar appearance' and set to NO.

Gigantopithecus answered 12/9, 2013 at 19:11 Comment(4)
What I need however is for the status bar to appear, as it does on iOS7... transparent, with views able to move behind it. What is happening is that the applicationFrame is actually set to {{0, 20},{748,1024}}. So it seems that the OS is accounting for that status bar and propagating the message to all views... How do I stop this? How do I tell it to NOT account for the status bar since it is transparent?Saltzman
A good rule to follow when you are coding is to never set anything regarding views to static location. Are you handling your view dynamically?Gigantopithecus
This would be bad practice and not the best way to handle it, but can you simply substract the status bar height from the y coordinate of your view? I can't imagine how this would be happening unless you are statically setting the view to a location. Can you post any code? I'd like to be able to replicate this behavior.Gigantopithecus
What do you mean by static? I have a "master" UIViewController with a UINavigationController inside of it and a UIScrollView as its root view. When I scroll this view, as soon as it stops... it offsets (jumps) the content by 20 pixels. The call stack points to a [UIScrollView _adjustContentOffsetIfNecessary]: function being called which adds 20 pixels to the contentOffset.y...Saltzman

© 2022 - 2024 — McMap. All rights reserved.