1

I have a navigation based Iphone application. Before root view(UITableView) I want to display a WELCOME view with few UILabels and a UIActivityIndicator on it.

This WELCOME view will be displayed when the application launch with the activity indicator. The data download (generally parsing XML and store data from server into local file system) will run in the background when the application launch.

When the download will finish this view will automatically dismiss and display the main root view (UITabkleView) with the data.

I am using

-(void)viewDidLoad{
 [self.indicator startAnimating]
 [self performSelectorInBackground:selector(startDataDownload).....]        
 [self.indicator stopAnimating]
}

But not working!!!
Any help would be highly appreciated.

Thanks

riko_marse
  • 81
  • 1
  • 6

4 Answers4

2

You are calling startAnimatiing and stopAnimating in queue.Call StopAnimating like this :

[self performselector:@selector(stop) withObject:nil afterDelay:3.0];


-(void)stop
{
   [self.indicator stopAnimating];
}
j0k
  • 22,600
  • 28
  • 79
  • 90
Sakshi
  • 1,060
  • 11
  • 25
1

Some suggestions:

Have you checked that self.indicator has a value? You could have an error in your NIB or creation.

Are you performing the data download on the main thread? If that is the case, you might not be giving the activity indicator a chance to display.

Rog
  • 17,070
  • 9
  • 50
  • 73
1

What's not working?

It'll obviously stop the animation instantly, as you're calling the stopAnimating method straight away rather than when the background thread has finished. (i.e.: The current thread won't stop just because you're loading something in the background via another thread.)

Also, are you sure you're setting up the thread environment correctly in your startDataDownload method?

John Parker
  • 54,048
  • 11
  • 129
  • 129
1

You might want to try a framework called MBProgressHud. It includes sample code as to how to implement these types of progress indicators.

But if you were to stay with your code, I'd suggest moving [self.indicator stopAnimating] into a new method that is called after startDataDownload is completed. As a test, try commenting out that line and seeing if it even starts to animate?

sudo rm -rf
  • 29,408
  • 19
  • 102
  • 161