I am having a strange problem.I am having a button , and on pressing the button I am doing
the following
- (IBAction)btnPressed:(id)sender {
[ _spinner startAnimating];//where _spinner is a ActivityIndicator
[self showResult];
}
-(void) showResult{
sleep(10);
resultText.text=@"Hi..Sorry.It has been a long wait";
}
But the spinner never starts animating , even though the showResult method gets called
properly. I feel this very strange . When I put [_spinner startAnimating] in the viewDidLoad
it works perfect. Any help is greatly appreciated.
sleep method get called on the main thread causing UI to hang, that’s why you aren’t able to see the activity indicator
one way to do this: