iPhone UIActivityIndicatorView not starting or stopping

前端 未结 6 2241
囚心锁ツ
囚心锁ツ 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-17 23:55

    All UI elements require to be on main thread

    [self performSelectorOnMainThread:@selector(startIndicator) withObject:nil waitUntilDone:NO];
    

    then:

    -(void)startIndicator{
        [activityIndicator startAnimating];
    }
    

提交回复
热议问题