iOS 7 -- navigationController is setting the contentInset and ContentOffset of my UIScrollView
Try setting self.automaticallyAdjustsScrollViewInsets = NO
in your main view controller.
This was introduced in iOS 7
so you might want to wrap that with an iOS version check, if you are supporting iOS 6
and below.
Update
If you are using storyboards, you can do this in the Interface Builder as well as by checking 'Adjust Scroll View Insets'
for your selected controller.
iOS 7 UIViewController (with navigation bar) doesn't inset UIScrollView
self.view = self.scrollView;
Works fine for me.
Tested with UIWebview:
- (void)viewDidLoad
{
[super viewDidLoad];
self.view = self.webView;
}
IOS9: UIScrollView offset in UINavigationController
I solved my issue. In auto layout, I wasn't setting my content view's height constraint.
Previously, I had pinned the bottom of the content view to the view controller that contained the UIScrollView.
I removed that pin and explicitly set the height. It works now.
UIScrollView and UINavigationController interactions
Ok, I have found it. UIViewController has a property called 'automaticallyAdjustsScrollViewInsets', which changes the contentOffset when showing/hiding navigationBar. Set it to no to prevent changes on the UIScrollView.
Source (and ios6 solution): https://stackoverflow.com/a/20325593/936957
UIScrollView how to set ContentInset and ScrollerInset
I'm not sure exactly what your question is, but I'm guessing your scrollview is not scrolling as expected.
You need to set the contentSize property to tell the scrollview that there is more content than just the viewable area (e.g. myScrollView.contentSize = CGSizeMake(520.0, 100.0);
)
If you want to start with the content centred as per your diagram, you can to set the contentOffset property. (e.g. myScrollView.contentOffset = CGPointMake((myScrollView.contentSize.width - myScrollView.frame.size.width) / 2, 0.0);
)
Related Topics
Swift Editor Placeholder in Source File
Uitableview Row Animation Duration and Completion Callback
Crashlytics: "We'Re Missing a Dsym to Process Crashes"
Xcode Is Looking for Core Data Entity Names with Dot; Not Compiling
iOS 7 App Icons, Launch Images and Naming Convention While Keeping iOS 6 Icons
Remove Gradient Background from Uiwebview
Scrollview Gesture Recognizer Eating All Touch Events
Programmatically Creating an Expanding Uitableviewcell
Given a View, How to Get Its Viewcontroller
How to Implement Pageview in Swiftui
How to Post String with Special Character and Thai Language Using Xml Parsing in Objective C
An App Id with Identifier '' Is Not Available. Please Enter a Different String
Ios: Keep an App Running Like a Service
Uitableview and Uiview with Keyboardwillshow
Uilabel Layer Cornerradius Negatively Impacting Performance
iOS Multiple Columns in Uitableview
Counting the Number of Lines in a Uitextview, Lines Wrapped by Frame Size