繁体   English   中英

Swift UIRefreshControl在iPhone 8上不起作用

[英]Swift UIRefreshControl not working on iPhone 8

我有一个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
}()

添加到视图:

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

我遇到了同样的问题,这是由于我将视图控制器设置为在情节提要中以模拟尺寸自由显示的缘故。 将其更改为固定可解决此问题。

也可以使用以下方法修复:

override func viewDidLayoutSubviews() { refreshControl?.didMoveToSuperview() super.viewDidLayoutSubviews() }

UIRefreshControl需要拉得太远

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM