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.

Umair Suraj
  • 480
  • 11
  • 22

1 Answers1

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
    }
AiOsN
  • 2,305
  • 2
  • 23
  • 29