我有自定义视图的代码
func customView(forEmptyDataSet scrollView: UIScrollView!) -> UIView! {
if isRefreshing {
let activityIndicator = UIActivityIndicatorView(frame: view.frame)
activityIndicator.center = view.center
activityIndicator.hidesWhenStopped = true
activityIndicator.activityIndicatorViewStyle = UIActivityIndicatorViewStyle.white
scrollView.addSubview(activityIndicator)
activityIndicator.startAnimating()
return activityIndicator
}
return nil
}
这是didTap按钮方法
func emptyDataSet(_ scrollView: UIScrollView, didTap button: UIButton) {
isRefreshing = true
self.collectionView?.reloadData()
searchData()
}
从viewDidAppear()调用SearchData(),活动指示器显示正常。
但是,如果我点击重新加载按钮,则在空白屏幕上执行customView方法中的代码并返回activityIndicator但不显示。
如何解决?
干杯, 阿希什