IOS7 : UIScrollView offset in UINavigationController

后端 未结 8 1908
攒了一身酷
攒了一身酷 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:30

    I had a similar problem, after dismissing a viewController, the contentOffset from my tableView was changed to (0, -64).

    my solution was a little weird, I tried all the other answers but had no success, the only thing that fixed my problem was to switch the tableView position in the controls tree of the .xib

    it was the first control in the parent View like this:

    before

    I moved the tableView right after the ImageView and it worked:

    after

    it seems that putting the table view in the first position was causing the trouble, and moving the table view to another position fixed the problem.

    P.D. I'm not using autoLayout neither storyboards

    hope this can help someone!

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

    @Justafinger's answer worked like a charm for me as well.

    Just wanted to add that this setting can also be adjusted easily from the interface builder.

    1. Select your view controller
    2. Click the 'Attributes Inspector' tab
    3. Uncheck 'Adjust Scroll View Insets'
    4. Enjoy!

    enter image description here

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

    Thank you guys for the solutions! I struggled for hours trying to solve the problem. Everything was ok when there was no Navigation Bar involved but it went haywire the moment I embedded the ViewController in a NavigationController.

    I solved it by unchecking the Adjust Scroll View Insets and the Under Top Bars. Both of these are located in the ViewController's Attribute Inspector. Thanks a million!

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

    I also face this problem.

    UIScrollView content size is calculate by OS as other sizes, origins provided by constraint system - that's why OS has doubtfulness.

    How to fix - You should explicitly define content size of UIScrollView:

    1. Embed scrollable content to UIView (I rename it to ContentView)
    2. Add constraints:

    ContentView.Weight = View.Weight and ContentView.Height = View.Height

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

    It seems like a work around solution is to view the storyboard file as "iOS 6.1 and earlier" (select storyboard file->File inspector->Interface Builder Document->View As. Positioning subviews in this mode shows the offset.

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

    I was running into this same issue, but I found a rather odd property on the ViewController in interface builder that seems to have been causing this for me. There is an "Extend Edges" set of check boxes. I removed the "Under Top Bars" check, and everything started laying out properly for me.

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