ios - Swift UIRefreshControl 不适用于 iPhone 8

标签 ios swift uicollectionview uikit uirefreshcontrol

我有一个 UIRefreshControl,它可以在除 iPhone 8 之外的所有设备上运行(既不能在物理设备上运行,也不能在模拟器上运行)。

在 iPhone 8 上,刷新指示器在 3/4 处停止并且从不调用刷新

这是你把它一直往下拉的样子:

enter image description here

创建刷新控件:

lazy var refreshControl: UIRefreshControl = {
    let refreshControl = UIRefreshControl()
    refreshControl.addTarget(self, action:
        #selector(TeamViewController.handleRefresh(_:)),
                             for: UIControlEvents.valueChanged)
    refreshControl.tintColor = UIColor.red

    return refreshControl
}()

添加到 View :

if #available(iOS 10.0, *) {
    myCollectionView.refreshControl = refreshControl
} else {
    myCollectionView.addSubview(refreshControl)
}

最佳答案

我有同样的问题,是由于我在 Storyboard中将 View Controller 设置为自由形式作为模拟大小造成的。将其改回已修复解决了该问题。

也可以通过以下方式修复:

覆盖函数 viewDidLayoutSubviews() { refreshControl?.didMoveToSuperview() super.viewDidLayoutSubviews() }

UIRefreshControl needs to be pulled down too far

关于ios - Swift UIRefreshControl 不适用于 iPhone 8,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/50852893/

相关文章:

ios - 核心数据 : Do child contexts ever get permanent objectIDs for newly inserted objects?

ios - 收到错误 : FT_Open_Face failed: error 2

ios - 以编程方式对水平居中元素进行偏移

ios - 未调用 UICollectionView cellForItemAtIndexPath 方法

ios - ViewController 显示不是来自 origin 0 的对象

ios - iOS XMPPFramework:如何解析didReceiveIQ?

swift - 为什么 Swift 中的赋值不会发生?

ios - 在多次打开应用程序后,弹出窗口要求用户对我的应用程序进行评分?

xcode - 将 Swift 与 OS X 首选项面板插件一起使用

ios - UICollectionView 单元格中的 UIImageView 不显示