UIActivityIndicator not working properly?

随声附和 提交于 2019-11-28 00:26:44
Andiih

Ole is pretty much correct, but there is a trick of you don't mind synchronous processing (often that it why you want to display the activity indicator in the first place).

First move your code that you want to process while the spinner is up to its own method. Then do

[spinner startAnimating];
[self performSelector:@selector(methodname) withObject:nil afterDelay:0];

The afterDelay:0 means on the next time through the run loop. That way the spinner gets started.

The animation will not start until your code returns control to the run loop. If your processing task blocks the main thread, the no UI updates will take place until it is finished. You should do your processing asynchronously (e.g. by starting an NSOperation).

Madhu

you should run in perform selector .

for ex:

[self performSelector:@selector(animation) withObject:nil afterDelay:0]

-(void)animation

{

NSAutoreleasepool *pool = [[NSAutorepleasepool alloc]init];

[indicatorView startAnimating];

[pool release];

}
Saran

This is an old question. I leaving my answer here, so that might help someone to solve their problem.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!