我有一个 UIRefreshControl
,它可以在除 iPhone 8 之外的所有设备上运行(既不能在物理设备上运行,也不能在模拟器上运行)。
在 iPhone 8 上,刷新指示器在 3/4 处停止并且从不调用刷新
这是你把它一直往下拉的样子:
创建刷新控件:
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()
}
关于ios - Swift UIRefreshControl 不适用于 iPhone 8,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/50852893/