I am trying to use the activity indicator in iOS and not able to. I followed a thread on Stackoverflow and using it like that. This is what i wrote:
-(void)viewDidLoad
{
[NSThread detachNewThreadSelector:@selector(threadStartAnimating:) toTarget:self withObject:self];
UITapGestureRecognizer *tGR = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(doThisForTap:)];
tGR.numberOfTapsRequired = 1;
[myRollTypeLabel addGestureRecognizer:tGR];
myRollTypeLabel.userInteractionEnabled = YES;
[self.scrollView addSubview:myRollTypeLabel];
}
- (void) threadStartAnimating:(id)data
{
self.activityIndicatorNew =[[UIActivityIndicatorView alloc] initWithActivityIndicatorStyle:UIActivityIndicatorViewStyleWhiteLarge];
self.activityIndicatorNew.color = [UIColor redColor];
[self.activityIndicatorNew startAnimating];
}
- (void)doThisForTap :(UIGestureRecognizer *)gest
{
//lots of computation.
}
- (void)viewWillDisappear:(BOOL)animated
{
[self.activityIndicatorNew stopAnimating];
self.activityIndicatorNew.hidden = YES;
}
But the activity indicator does not show up at all? In the method "doThisForTap" i do computation and move to another UIViewController. But i cannot see the activity indicator. What am i doing wrong? If you need more info,please ask. Thanks..