我的单元格中的活动指示器出现此问题。我在此处以这种方法启动动画,然后从此处下载数据,然后重新加载表格视图,并在numbersResponseData.length != 0时调用停止动画,但看不到活动指示器。

我有一个附件视图箭头,它在加载时向左移动,我只是看不到指示器。

这在tableView:cellForRowAtIndexPath:方法内部:

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
}


更新时间:

我在if语句的不同部分内添加了UIActivityIndi​​cator调用,现在将活动指示器应用于每个单元格,但现在可以看到它们了。

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
    }


我已经调试了.row if语句,并对其进行了挑衅的调用。.我只是不明白为什么它会从一个if语句而不是第二个if语句起作用。

最佳答案

我认为您的UIActivityIndi​​catorView隐藏在UITableView后面。转储此代码,并检查是否可以查看此指示器

    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];


删除使用这个,

    [subViewActivityIndicator removeFromSuperview];

10-06 09:45