【问题标题】:UIRefreshControl flickerUIRefreshControl 闪烁
【发布时间】: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


    【解决方案1】:

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

    tableView.addSubview(refreshControl)
    

    tableView.insertSubview(refreshControl, atIndex: 0)
    

    感谢这条评论:UIRefreshControl without UITableViewController

    【讨论】:

    • 即便如此,从 ios 11.x 开始的表格上方仍显示 refreshesControl(ios 9 工作正常)
    • 为我修复了它。这太奇怪了
    【解决方案2】:

    将 UIRefreshControl 的父视图的背景颜色更改为与 UIRefreshControl 的背景颜色相同。

    类似:

    refreshControl.Superview.BackgroundColor = refreshControl.BackgroundColor

    【讨论】:

      猜你喜欢
      • 2015-07-30
      • 2013-11-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2017-03-08
      • 1970-01-01
      相关资源
      最近更新 更多