IOS7 : UIScrollView offset in UINavigationController

后端 未结 8 1909
攒了一身酷
攒了一身酷 2020-12-04 04:57

I\'m currently migrating my app on ios 7 and I\'ve been stuck for hours on the new navigationcontroller/bar management.

Before, when we had a navigation controller,

相关标签:
8条回答
  • 2020-12-04 05:49

    OK so i found the solution, I have set in my controller the property:

    self.automaticallyAdjustsScrollViewInsets = false
    

    I don't really understand the true benefit of this property though, (or why the default value is true)

    The only documentation i found was there:

    • https://web.archive.org/web/20160405135605/https://developer.apple.com/library/ios/documentation/userexperience/conceptual/TransitionGuide/AppearanceCustomization.html
    • https://developer.apple.com/documentation/uikit/uiviewcontroller/1621372-automaticallyadjustsscrollviewin

    Update

    In iOS 11 automaticallyAdjustsScrollViewInsets is deprecated

    You should now use:

    self.tableView.contentInsetAdjustmentBehavior = .never
    

    I also encourage you to check this question and its answer to get a better understanding of those properties

    0 讨论(0)
  • 2020-12-04 05:52

    With automaticallyAdjustsScrollViewInsets set to YES (the default setting) there is a mismatch in scrollview positioning between ios6 and ios7, so to make them consistent you need to disable this setting. However, ios6 will crash if it comes across automaticallyAdjustsScrollViewInsets, so you either need to make a programatic change of automaticallyAdjustsScrollViewInsets conditional on ios7 or else switch off the option using the storyboard/NIB

    0 讨论(0)
提交回复
热议问题