UIActivityIndi​​catorView 显示为空白

发布于 2024-12-26 01:58:24 字数 1881 浏览 0 评论 0原文

我的手机中的活动指示器遇到了这个问题。我在此方法中启动动画,然后从那里下载数据。当 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 语句中工作。

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.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

沐歌 2025-01-02 01:58:24

我认为你的 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];

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];
匿名。 2025-01-02 01:58:24

您是从 UI 循环还是从工作线程调用此代码?如果您从工作线程调用,则需要使用performSelectorOnMainThread: 来调用UI 更改。请参考:

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

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/

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文