Activity Indicator Problem

Discussion in 'iOS Programming' started by RagingGoat, Aug 6, 2013.

  1. RagingGoat macrumors 6502

    Joined:
    Jun 21, 2010
    #1
    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];
    
     
  2. waterskier2007 macrumors 68000

    waterskier2007

    Joined:
    Jun 19, 2007
    Location:
    White Lake, MI
    #2
    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
     
  3. RagingGoat thread starter macrumors 6502

    Joined:
    Jun 21, 2010
    #3
    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.
     
  4. RagingGoat thread starter macrumors 6502

    Joined:
    Jun 21, 2010
    #4
    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.
     
  5. Duncan C macrumors 6502a

    Duncan C

    Joined:
    Jan 21, 2008
    Location:
    Northern Virginia
    #5

    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.
     
  6. RagingGoat thread starter macrumors 6502

    Joined:
    Jun 21, 2010
    #6
    Thanks. I'll take a look and see if I can get this working.
     
  7. waterskier2007 macrumors 68000

    waterskier2007

    Joined:
    Jun 19, 2007
    Location:
    White Lake, MI
    #7
    Ah, when I ready your post I assumed it was an asynchronous task.
     

Share This Page