iOS 7 -- Navigationcontroller Is Setting the Contentinset and Contentoffset of My Uiscrollview

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.

Sample Image

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



Leave a reply



Submit