C.Johns
C.Johns

Reputation: 10245

UIActivityIndicatorView appears blank

I am having this issue with my activity indicator in my cell. I start the animation in this method here then download the data from there I reload the table view and call stop animating when numbersResponseData.length != 0 but I cannot see the activity indicator.

I have an accessory view arrow thingy that moves to the left when its loading I just cannot see the indicator.

This is inside the tableView:cellForRowAtIndexPath: method:

if(indexPath.section == 0)
{        
    if ((indexPath.row == 0) && (numbersResponseData.length == 0))
    {
        cellActivityIndicator =
            [[UIActivityIndicatorView alloc]
                initWithActivityIndicatorStyle:UIActivityIndicatorViewStyleGray];
        [cellActivityIndicator startAnimating];
        [cell setAccessoryView:cellActivityIndicator];

        // Call ASIHTTPRequest methods to start xml download/cache process
        [self setRequestString:@"Numbers.xml"];
    }
    //will set other cells up later
}

UPdate:

I added the UIActivityIndicator call inside a different part of my if statement and now it applied the activity indicator to every cell but now I can see them.

if(indexPath.section == 0)
    {        
            cellActivityIndicator =
                [[UIActivityIndicatorView alloc]
                    initWithActivityIndicatorStyle:UIActivityIndicatorViewStyleGray];
            [cellActivityIndicator startAnimating];
            [cell setAccessoryView:cellActivityIndicator];
        if ((indexPath.row == 0) && (numbersResponseData.length == 0))
        {
            cellActivityIndicator =
                [[UIActivityIndicatorView alloc]
                    initWithActivityIndicatorStyle:UIActivityIndicatorViewStyleGray];
            [cellActivityIndicator startAnimating];
            [cell setAccessoryView:cellActivityIndicator];

            // Call ASIHTTPRequest methods to start xml download/cache process
            [self setRequestString:@"Numbers.xml"];
        }
        //will set other cells up later
    }

I have debugged the .row if statement and its defiantly getting called.. I just don't understand why it would work from one if statement but not the next.

Upvotes: 0

Views: 300

Answers (2)

AAV
AAV

Reputation: 3803

i think your UIActivityIndicatorView is hiding behind the UITableView. Dump this code and check do you able to see this indicator on view or not

    subViewActivityIndicator = [[[UIActivityIndicatorView alloc]initWithActivityIndicatorStyle:UIActivityIndicatorViewStyleWhiteLarge] autorelease];
subViewActivityIndicator.frame=CGRectMake(150, 220, 37, 37);
subViewActivityIndicator.color = [UIColor colorWithRed:0.6 green:1 blue:0 alpha:1.0];
[self.tableview addSubview:subViewActivityIndicator];
[subViewActivityIndicator startAnimating];

to remove use this,

    [subViewActivityIndicator removeFromSuperview];

Upvotes: 1

Fletch
Fletch

Reputation: 963

Are you calling this code from the UI loop, or from a worker thread? You will need to use performSelectorOnMainThread: to invoke UI changes if you're calling from a worker thread. Please refer to:

http://blog.jayway.com/2010/03/30/performing-any-selector-on-the-main-thread/

Upvotes: 0

Related Questions