How to show activity indicator while tableView loads?

前端 未结 12 1550
说谎
说谎 2021-01-30 21:44

When I switch between my tabs it loads some seconds and I want to know that my data is loading. For that I decided to add an activity indicator.

I wrote a little functio

12条回答
  •  粉色の甜心
    2021-01-30 22:06

    Swift 2+

        class ViewController: UITableViewController {
            weak var activityIndicatorView: UIActivityIndicatorView!
    
            override func viewDidLoad() {
                super.viewDidLoad()
                let activityIndicatorView = UIActivityIndicatorView(activityIndicatorStyle: UIActivityIndicatorViewStyle.Gray)
                tableView.backgroundView = activityIndicatorView
                self.activityIndicatorView = activityIndicatorView
                activityIndicatorView.startAnimating()
    
            }
            ...
        }
    

提交回复
热议问题