iOS 11 large title navigation bar snaps instead of smooth transition

前端 未结 5 495
佛祖请我去吃肉
佛祖请我去吃肉 2021-01-31 17:10

I\'m facing an issue where the large title navigation bar collapses very abruptly when scrolling on a UITableView embedded inside of a UIViewController. The problem seems to onl

相关标签:
5条回答
  • 2021-01-31 17:36

    I had a similar looking issue and solved it by removing UINavigationBar.appearance().isTranslucent = false from my AppDelegate.

    UPDATE: If you don't want translucency, you should enable extendedLayoutIncludesOpaqueBars. That way all the glitches are fixed.

    0 讨论(0)
  • 2021-01-31 17:38

    I faced same issue - I had UIViewController embedded in UINavigationController, the UIViewController had tableview with leading, trailing, top, bottom constraints to safe area. The whole tableview behaved jumpy / snappy. The trick was to change top constraint of tableview to superview.

    Here I recorded changing the constraint tableview iOS 11 bug constraint change

    0 讨论(0)
  • 2021-01-31 17:43

    Put this line of code on your UIViewController containing UITableView and works fine for me.

    Swift

    extendedLayoutIncludesOpaqueBars = true;
    

    Objective-C

    self.extendedLayoutIncludesOpaqueBars = YES;
    

    Set UITableView AutoLayout top space to "Superview" instead of "Safe Area"

    0 讨论(0)
  • 2021-01-31 17:52

    In Interface Builder:

    1. Select your "viewController".
    2. Attribute Inspector tick "Under Opaque Bars" and "Under Top Bars".
    3. Make your top constraints of your scrollView second Item to "SuperView" not "SafeArea".

    It worked with me.

    Reference

    0 讨论(0)
  • 2021-01-31 18:02

    Soolar's answer is right, but I don't know how to fix it in storyboard. Finally I solved the problem with Roman's solution in another question, by adding:

    NSLayoutConstraint.activate([
        scrollView.topAnchor.constraint(equalTo: view.topAnchor),
        scrollView.leftAnchor.constraint(equalTo: view.leftAnchor),
        scrollView.bottomAnchor.constraint(equalTo: view.bottomAnchor),
        scrollView.rightAnchor.constraint(equalTo: view.rightAnchor)
    ])
    

    in viewDidLoad.

    Original answer: https://stackoverflow.com/a/48321447/1386369

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