views:

619

answers:

1

I have a UIActivityIndicatorView that displays with a message to indicate to the user that the next view is loading when the user switches views or is directed to another view on say a button click. I have added the UIActivityIndicatorView so that the data that im fetching to be displayed in the current view from an api can complete before user interaction is enabled. The UIActivityIndicatorView animates correctly with the wait message as the current view loads in the background. However even after the view loading is complete, the UIActivityIndicatorView doesnt stop animating and continues forever!! I have tried both [stop Animating] as well as removefromSuperview but neither seem to work. I need to resolve this issue urgently.

Heres the code: -(void)showWorkInProgress { NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];

   progressAlert = [[UIAlertView alloc] initWithTitle:@"Loading Data"
                                                           message:@"Please wait..."
                                                            delegate: self
                                               cancelButtonTitle: nil
                                                otherButtonTitles: nil];


   activityView = [[UIActivityIndicatorView alloc]

initWithActivityIndicatorStyle:UIActivityIndicatorViewStyleWhite]; activityView.frame = CGRectMake(139.0f-18.0f, 80.0f, 37.0f, 37.0f); [progressAlert addSubview:activityView];

   [activityView startAnimating];

   [progressAlert show];

   [pool drain];

} - (void)viewDidLoad {

   self.title = @"WordLife";
   UIImage *image = [UIImage imageNamed: @"cena.png"];
   UIImageView *imageview = [[UIImageView alloc] initWithImage: image];
   self.navigationItem.titleView = imageview;

   [imageview release];
   self.navigationItem.leftBarButtonItem.title = @"Back";


   [activityView removeFromSuperview];
   activityView = nil;
   [super viewDidLoad];

}

A: 

Can you post your code? Maybe you replace the first UIActivityIndicatorView by another or call the sopAnimating selector before it starts animating?

Maybe a better solution:
Place a NSLog(@"Is the function called?") after (or before) you call the stopAnimating-selector so you can see (in the log) if the selector which calls the 'stopAnimating'-selector is called.

Tim van Elsloo