Assertion failure in -[UITableView _addScrollViewScrollObserver:] while using large title navigation ios 11
Asked Answered
F

1

8

I have tab bar controller with view controller that has only a table view in it.

I am setting navigation bar large title using code:

if (@available(iOS 11.0, *)) {
        [[UINavigationBar appearance] setPrefersLargeTitles:YES];
    } else {
        // Fallback on earlier versions
    }

It's crashing app when I open tab 2nd time. or randomly shifting tabs with following message.

Error message is shown below:

Assertion failure in -[UITableView _addScrollViewScrollObserver:], /BuildRoot/Library/Caches/com.apple.xbs/Sources/UIKit/UIKit-3694.4.18/UIScrollView.m:7693

Any idea to fix issue. Thanks.

Frisket answered 15/11, 2017 at 8:0 Comment(1)
I get this exception even on iOS 12 when my view is inside a tabBarControllerProjective
B
0

Crash is caused by this method [[UINavigationBar appearance] setPrefersLargeTitles:YES]; Don't use above method.

Use following code in your UIViewControllers

if (@available(iOS 11.0, *))
    {
        self.navigationController.navigationBar.prefersLargeTitles = true;
        self.navigationController.navigationBar.topItem.title = @"Your Title here";
        self.navigationController.navigationItem.largeTitleDisplayMode = UINavigationItemLargeTitleDisplayModeAutomatic;

        NSDictionary *attributes = @{NSForegroundColorAttributeName: [UIColor redColor]};
        self.navigationController.navigationBar.largeTitleTextAttributes = attributes;
    }
    else
    {
        // Fallback on earlier versions
    }
Buonomo answered 16/11, 2017 at 7:32 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.