How do I programmatically slide the UITableView down to reveal the underlying UIRefreshControl

后端 未结 4 1854
天涯浪人
天涯浪人 2021-02-04 01:06

How can I reveal the UIRefreshControl when I update the table programmatically? Using [self.refreshControl beginRefreshing] make the spinner animate but does not reveal it.

4条回答
  •  [愿得一人]
    2021-02-04 01:35

    For Swift 5, this is the only working version for me.

    extension UIRefreshControl {
    
        func beginRefreshingManually() {
            if let scrollView = superview as? UIScrollView {
                scrollView.setContentOffset(CGPoint(x: 0, y: scrollView.contentOffset.y - frame.height), animated: false)
            }
            beginRefreshing()
            sendActions(for: .valueChanged)
        }
    
    }
    

提交回复
热议问题