iOS 11 prefersLargeTitles not updating until scroll

前端 未结 24 2347
轻奢々
轻奢々 2021-01-31 07:25

I implemented a basic UIViewController with a UITableView that\'s wrapped in a UINavigationController. I set prefersLargeTitles to true:

override fu         


        
24条回答
  •  被撕碎了的回忆
    2021-01-31 08:07

    Modifying the contentInset of the tableView with top:1 will force the NavigationBar to expand and display the large titles.

    Obj-C

    -(void) viewWillAppear:(BOOL)animated {
        if (@available(iOS 11.0, *)) {
            tableView.contentInset = UIEdgeInsetsMake(1, 0, 0, 0);
        }
    }
    

    Swift

    override func viewWillAppear(_ animated: Bool) {
        if #available(iOS 11.0, *) {
            tableView.contentInset = UIEdgeInsetsMake(1, 0, 0, 0)
        }
    }
    

    Note: If you have a tableView.reloadData() in your viewWillAppear make sure to call it after editing the contentInset

提交回复
热议问题