【发布时间】:2015-03-16 19:07:09
【问题描述】:
我在 iOS 8 下实现 UIRefreshControl 时遇到了一种闪烁。每次我第一次到达 tableView 的顶部时(即应用刚刚启动时),我都会看到下面 gif 中显示的闪烁。这不会发生在随后的任何时候我来到 tableView 的顶部,直到再次加载此视图,所以在我在应用程序的另一个视图中执行某些操作或完全重新启动它之后。
这是我的应用程序 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 是在 viewDidLoad() 函数之外声明的,因为我想从我的 updateData() 函数中调用 endRefreshing 方法。这似乎是显而易见的做法。
【问题讨论】:
标签: ios uitableview uirefreshcontrol