Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

RagingGoat

macrumors 6502
Original poster
Jun 21, 2010
308
15
I have a table view that gets it's data from an RSS feed. I'm trying to get my activity indicator to show while the table view is loading in my iPad app. It works fine on iPhone but the indicator never appears on the iPad. Any suggestions?

Code:
@implementation ActionAlertsIpad
{
    UIActivityIndicatorView *loadingIndicator;
}

In viewDidLoad
Code:
CGFloat width = CGRectGetWidth(self.view.bounds);
    CGFloat height = CGRectGetHeight(self.view.bounds);

loadingIndicator = [[UIActivityIndicatorView alloc] initWithActivityIndicatorStyle:UIActivityIndicatorViewStyleGray];
    loadingIndicator.center = CGPointMake(width/2, height/2);
    loadingIndicator.hidesWhenStopped = YES;
    [self.view addSubview:loadingIndicator];
    [loadingIndicator startAnimating];

In connectionDidFinishLoading:
Code:
[loadingIndicator stopAnimating];
 
What is the subclass of your view controller. Is it a UITableViewController? If so, the tableView might be above the view so the indicator is below the tableView. You may want to look into that
 
Yes, it is a UITableViewController. I have the same code in the iPhone app and the activity indicator shows fine. The only difference is that the iPad app is a split view so when this table view loads, it replaces the master view controller.
 
I'm trying to get the activity indicator to show up before the table view shows. The table view pulls data from an RSS feed so it doesn't show until the data is loaded. This is why I want the activity indicator to show in the center of the empty view.
 
I'm trying to get the activity indicator to show up before the table view shows. The table view pulls data from an RSS feed so it doesn't show until the data is loaded. This is why I want the activity indicator to show in the center of the empty view.


This comes up so often that I wrote a tutorial on iPhone Dev SDK explaining the situation. Here's the link:

How to display an activity indicator before beginning a long task

By the way, it's generally a bad idea to download content synchronously and lock up the UI. Better to use NSURLConnection to start an async download.
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.