iPhone UIActivityIndicatorView not starting or stopping

前端 未结 6 2300
囚心锁ツ
囚心锁ツ 2020-12-17 23:32

When I call startAnimating on a UIActivityIndicatorView, it doesn\'t start. Why is this?

[This is a blog-style self-answered question. The solution below works for

6条回答
  •  温柔的废话
    2020-12-18 00:15

    If needed, swift 3 version:

    func doSomething() {
        activityIndicator.startAnimating()
        DispatchQueue.global(qos: .background).async {
            //do some processing intensive stuff
            DispatchQueue.main.async {
                self.activityIndicator.stopAnimating()
            }
        }
    }
    

提交回复
热议问题