iOS中是否有类似tableViewWillEndDisplayingCell的方法用于UITableViewDelegate?

iOS中是否有类似tableViewWillEndDisplayingCell的方法用于UITableViewDelegate?,ios,objective-c,uitableview,cell,Ios,Objective C,Uitableview,Cell,我想在iPhone应用程序中的表格视图中的单元格消失之前将其淡入淡出。当它即将出现时,我使用 - (void) tableView: (UITableView *) tableView willDisplayCell: (UITableViewCell *) cell forRowAtIndexPath: (NSIndexPath *) indexPath 使用0.3秒动画将alpha从0更改为1 我想,当它即将消失时,从1变为0。是否有与上述方法类似的方法,或者我如何才能做到这一点

我想在iPhone应用程序中的表格视图中的单元格消失之前将其淡入淡出。当它即将出现时,我使用

- (void) tableView: (UITableView *) tableView
   willDisplayCell: (UITableViewCell *) cell
 forRowAtIndexPath: (NSIndexPath *) indexPath
使用0.3秒动画将alpha从0更改为1

我想,当它即将消失时,从1变为0。是否有与上述方法类似的方法,或者我如何才能做到这一点

我不想使用标准的iOS
UITableViewRowAnimationFade
,因为我不想在重新加载表时进行任何其他转换

编辑: 我正在重新加载表视图的内容。假设我单击了一个按钮,它会在我的表中重新加载数据。这就是我想要淡出现有单元格并淡入新单元格的时候


我使用的控制器是一个基本的
UIViewController
实现
UITableViewDataSource
UITableViewDelegate
UIScrollViewDelegate
协议。

您试过这个吗

- (void)tableView:(UITableView *)tableView
didEndDisplayingCell:(UITableViewCell *)cell
forRowAtIndexPath:(NSIndexPath *)indexPath

我想这就是你想要的。

这有点像黑客,但应该可以:

- (void)scrollViewDidScroll:(UIScrollView *)scrollView {
    //loop through visible indexPaths
    for (NSIndexPath *indexPath in [self.tableView indexPathsForVisibleRows]) {
        //get each cell
        UITableViewCell *cell = [self.tableView cellForRowAtIndexPath:indexPath];
        //get its location
        CGRect rectInTableView = [self.tableView rectForRowAtIndexPath:indexPath];
        //set its alpha based on whether or not its going off the screen at the top.
        cell.alpha = 1 + rectInTableView.origin.y / rectInTableView.size.height;
    }

}
我找到了解决办法

在调用
[self.tableView reloadData]
之前,我正在设置所有可见单元格的动画,使其淡出。我得到所有可见的单元格,并通过

for (NSIndexPath *indexPath in [self.tableView indexPathsForVisibleRows])
{
    // here I animate cells to fade out
}
(感谢@AlexKoren为我展示了遍历可见单元格的方法)

因为我使用的是
[self.tableView reloadData]
,没有任何额外的iOS内置动画,所以单元格正在消失。因此,现在它们先是淡入淡出,然后我的新细胞随着中定义的动画淡入淡出

- (void) tableView: (UITableView *) tableView
   willDisplayCell: (UITableViewCell *) cell
 forRowAtIndexPath: (NSIndexPath *) indexPath
重要信息:动画完成后,我正在重新加载表视图。若我在迭代单元格之后调用
[self.tableView reloadData]
,它将在显示动画之前重新加载表格。因为我知道完成我使用的动画需要多长时间

dispatch_time_t popTime = dispatch_time(DISPATCH_TIME_NOW, delay * NSEC_PER_SEC);
dispatch_after(popTime, dispatch_get_main_queue(), ^(void)
                {
                    [self.tableView reloadData];
                });

使用之前计算的
延迟

您可以尝试viewDidDisappear@T_77这是一个
UIViewController
方法,不是任何可以用于单个单元格的方法(a
UIView
)。作者提到了uitableview,但没有提到uitableviewcontroller。所以我假设作者在UIViewController中有tableview只是为了澄清——如果一个单元格即将消失,你的意思是它即将被删除吗?或者,当整个表即将消失时,是否要淡出每个单元格?我确实建议使用集合视图,它允许您通过布局属性进行这种淡出。在完全从UITableView中消失后,将调用该视图,这将起作用,但我希望在重新加载tableview内容时,所有可见单元格都淡出。只有当它们因为滚动而即将消失时,才会褪色。