斯威夫特:刷新后的“Poppy”LargeTitles

时间:2018-04-21 09:13:54

标签: swift

我有这种情况,我的LargeTitles在刷新完成后“弹出”。我已经在这个链接的post中进行了相应的实现,但是以编程方式实现,但收到了这样的问题:

enter image description here

我的代码如下:

//Declarations:
lazy var tableView: UITableView = {
    let tv = UITableView(frame: .zero, style: .grouped)
    tv.translatesAutoresizingMaskIntoConstraints = false
    tv.dataSource = self
    tv.delegate = self
    tv.backgroundColor = .customGroupedTableViewBackgroundColor
    tv.contentInset.top = -36
    return tv
}()

lazy var refreshControl: UIRefreshControl = {
    let rc = UIRefreshControl(frame: .zero)
    rc.addTarget(self, action: #selector(refreshControlDidRefresh), for: .valueChanged)
    return rc
}()

//At viewDidLoad()
view.addSubview(tableView)

navigationController?.navigationBar.barTintColor = .white
navigationController?.navigationBar.prefersLargeTitles = true
navigationItem.title = "Carparks"

tableView.topAnchor.constraint(equalTo: view.topAnchor).isActive = true
tableView.leadingAnchor.constraint(equalTo: view.safeAreaLayoutGuide.leadingAnchor).isActive = true
tableView.trailingAnchor.constraint(equalTo: view.safeAreaLayoutGuide.trailingAnchor).isActive = true
tableView.bottomAnchor.constraint(equalTo: view.bottomAnchor).isActive = true

tableView.register(UITableViewCell.self, forCellReuseIdentifier: "cell")
tableView.estimatedRowHeight = 200
tableView.rowHeight = UITableViewAutomaticDimension

tableView.refreshControl = refreshControl

任何建议我如何删除这种快速行为?

1 个答案:

答案 0 :(得分:0)

好的,我设法通过将tv.contentInsetAdjustmentBehavior = .never添加到我的tableView声明中来解决它:

lazy var tableView: UITableView = {
    let tv = UITableView(frame: .zero, style: .grouped)
    tv.translatesAutoresizingMaskIntoConstraints = false
    tv.dataSource = self
    tv.delegate = self
    tv.backgroundColor = .customGroupedTableViewBackgroundColor
    tv.contentInset.top = -35
    tv.contentInsetAdjustmentBehavior = .never
    return tv
}()