从表中删除 CustomCell

发布于 2024-11-26 13:30:00 字数 349 浏览 0 评论 0原文

我在 UITableViewCell(CustomCell) 中使用 NSURLConnection 的委托方法。我在单元格中显示下载进度。下载完成后,将调用connectionDidFinishLoading。下载完成后,我需要删除显示下载进度的单元格。下图对此进行了解释。

在此处输入图像描述

这里首先完成了第三个单元格中文件的下载,另外两个单元格中的下载是进行中。下载完成后我需要删除单元格。在这种情况下,我必须删除完成下载的第三个单元格。
所以,有人帮我删除connectionDidFinishLoading 中的单元格。先感谢您。

I am using the delegate method of NSURLConnection in UITableViewCell(CustomCell). I am showing the download progress in the cell. When the download completes, connectionDidFinishLoading is called. I need to remove the cell where I show the download progress, once the download completes. It is explained in the below image.

enter image description here

Here the download of the file in the third cell is completed first and the downloads in the other two cell are in progress. I need to delete the cell once the download completes. In this case, I have to delete the third cell in which the download was completed.
So, somebody help me to remove the cell in connectionDidFinishLoading. Thank you in advance.

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

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

发布评论

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

评论(2

追我者格杀勿论 2024-12-03 13:30:00
while creating cell set the tag 

cell.tag=55;

in connectdidFinishing u can remove it by

[[self.view viewWithTag:55] removeFromSuperview];
while creating cell set the tag 

cell.tag=55;

in connectdidFinishing u can remove it by

[[self.view viewWithTag:55] removeFromSuperview];
木緿 2024-12-03 13:30:00

当您开始下载并更新自定义单元格以显示进度时,请将 indexPath 保存

在标头中委托的某处:

NSIndexPath *targetCellIP;
@property (nonatomic, retain)NSIndexPath *targetCellIP;

在实现中:

@synthesize targetCellIP;

// Somewhere where you update cell layout to show progress save it's indexPath
[self setTargetCellIP:....];

// After download is completed, remove cell from data model
[[dataModel objectAtIndex:[targetCellIP section]] 
                                        removeObjectAtIndex:[targetCellIP row]];

// Remove cell from table
[tableView deleteRowsAtIndexPaths:[NSArray arrayWithObject:targetCellIP] 
                 withRowAnimation:UITableViewRowAnimationMiddle];

仅当您只有一个带有要删除的进度的单元格时,此方法才有效,在其他情况下,您可以将索引存储在数组中,并在需要时使用它们。

When you start download and update custom cell to show progress, save indexPath somewhere in you delegate

in header:

NSIndexPath *targetCellIP;
@property (nonatomic, retain)NSIndexPath *targetCellIP;

in implementation:

@synthesize targetCellIP;

// Somewhere where you update cell layout to show progress save it's indexPath
[self setTargetCellIP:....];

// After download is completed, remove cell from data model
[[dataModel objectAtIndex:[targetCellIP section]] 
                                        removeObjectAtIndex:[targetCellIP row]];

// Remove cell from table
[tableView deleteRowsAtIndexPaths:[NSArray arrayWithObject:targetCellIP] 
                 withRowAnimation:UITableViewRowAnimationMiddle];

This method will be good only if you have only one cell with progress which you want to remove, in other case, you can store indices in array and use them when ether you need them.

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