gpt4 book ai didi

ios - UIRefreshControl 闪烁

转载 作者:行者123 更新时间:2023-12-01 17:51:32 26 4
gpt4 key购买 nike

我在 iOS 8 下实现 UIRefreshControl 时遇到了一种闪烁。每次我第一次到达 tableView 的顶部时(即应用程序刚刚启动时),我都会看到下面的 gif 中显示的闪烁。这不会发生在随后的任何时候我来到 tableView 的顶部,直到再次加载该 View ,所以在我在应用程序的另一个 View 中执行某些操作或完全重新启动它之后。

screen recording of flicker

这是我的应用程序 viewDidLoad() 中的代码:

let refreshControl = UIRefreshControl()

override func viewDidLoad() {
super.viewDidLoad()

// Doing this here to prevent the UIRefreshControl sometimes looking messed up when waking the app
self.refreshControl.endRefreshing()

updateData()

refreshControl.backgroundColor = UIColor(hue: 0.58, saturation: 1.0, brightness: 0.43, alpha: 1.0)
refreshControl.tintColor = UIColor.whiteColor()
refreshControl.addTarget(self, action: "updateData", forControlEvents: UIControlEvents.ValueChanged)
tableView.addSubview(refreshControl)
}

refreshControl 在 vi​​ewDidLoad() 函数之外声明,因为我想从 updateData() 函数中调用 endRefreshing 方法。这似乎是这样做的明显方式。

最佳答案

我能够通过更改以下行来解决此问题

tableView.addSubview(refreshControl)


tableView.insertSubview(refreshControl, atIndex: 0)

感谢这条评论: UIRefreshControl without UITableViewController

关于ios - UIRefreshControl 闪烁,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29085003/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com