表格视图中的活动指示器

发布于 2024-11-28 16:32:58 字数 102 浏览 4 评论 0原文

我有一个包含 xml 解析对象的表视图。

我想在此表视图中实现活动指示器,如果数据加载完成,活动指示器会自动停止。

如何做到这一点?

提前致谢

I have a tableview contains xml parsed objects.

I want to implement activity indicator in this tableview ,if the data loading is completed activity indicator stops automatically.

How to do this?.

Thanks in advance

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

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

发布评论

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

评论(3

你在我安 2024-12-05 16:32:59

首先,您需要进行异步调用来获取 xml 数据。

在进行调用之前启动活动指示器,然后在委托方法中,当您收到数据时停止活动指示器,代码如下所示。

- (void)getAsyncData
{
    // do something here......
    [indicator startAnimating];
    [NSURLConnection connectionWithRequest:urlRequest delegate:self];
}

#pragma mark -
#pragma mark NSURLConnection delegate
-(void)connection:(NSURLConnection *)connection didReceiveData:(NSData *)data
{
    [responseData appendData:data];
}

-(void)connectionDidFinishLoading:(NSURLConnection *)connection
{
    NSXMLParser *xmlParser = [[NSXMLParser alloc] initWithData:responseData];
    xmlParser.delegate = self;
    [xmlParser parse];
    [xmlParser release];
    [indicator stopAnimating];
}

First of all you need to make an async call to get your xml data.

Start your activity indicator before making the call then in the delegate method when you receive the data stop the activity indicator the code looks something like this.

- (void)getAsyncData
{
    // do something here......
    [indicator startAnimating];
    [NSURLConnection connectionWithRequest:urlRequest delegate:self];
}

#pragma mark -
#pragma mark NSURLConnection delegate
-(void)connection:(NSURLConnection *)connection didReceiveData:(NSData *)data
{
    [responseData appendData:data];
}

-(void)connectionDidFinishLoading:(NSURLConnection *)connection
{
    NSXMLParser *xmlParser = [[NSXMLParser alloc] initWithData:responseData];
    xmlParser.delegate = self;
    [xmlParser parse];
    [xmlParser release];
    [indicator stopAnimating];
}
栀梦 2024-12-05 16:32:59

完成解析操作后,向 tableview 类发出通知,在该方法中您可以重新加载 tableView 并停止活动指示器。

after finishing the parse operation, give a notification to the tableview class , in that method you can reload the tableView and also stop the activity indicator .

梦回旧景 2024-12-05 16:32:59

我希望,UITableView 的“- (void)endUpdates”可能是在表格完成所有操作后停止指示器的最佳位置。

I hope, UITableView's "- (void)endUpdates" could be best place to stop your indicator when everything is done with the table.

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