Ios 在带有动画的UITableView中的2个UITableViewCell之间添加UITableViewCell
现在我正在制作一个iPad应用程序,它包含一个左右滑动的Ios 在带有动画的UITableView中的2个UITableViewCell之间添加UITableViewCell,ios,uiview,uitableview,Ios,Uiview,Uitableview,现在我正在制作一个iPad应用程序,它包含一个左右滑动的UITableView,我有一个基于NSNotification的系统,让UITableView控制器知道何时发生滑动。我需要在移动的单元格下方和移动单元格下方的单元格上方显示一个UITableViewCell。我想做一个折叠动画,就像在应用程序中看到的那样清晰,但没有捏手势(即自动折叠)。我发现这个图书馆叫做。但是,它不支持UITableView。在本教程中,我还研究了捏手势,但是本教程没有告诉我如何自动设置动画,因为它需要用户做捏手势。
UITableView
,我有一个基于NSNotification
的系统,让UITableView控制器知道何时发生滑动。我需要在移动的单元格下方和移动单元格下方的单元格上方显示一个UITableViewCell
。我想做一个折叠动画,就像在应用程序中看到的那样清晰,但没有捏手势
(即自动折叠)。我发现这个图书馆叫做。但是,它不支持UITableView
。在本教程中,我还研究了捏手势
,但是本教程没有告诉我如何自动设置动画,因为它需要用户做捏手势。我环顾了一下网络,似乎什么也找不到。我将感谢任何帮助
谢谢使用MPFoldTransition
的从视图:到视图:…
的转换,这是完全可能的。我创建了一个示例项目,如果您愿意,我可以链接到该项目,但这一切实际上归结为:
- (void)addNewTableCellToIndexPath:(NSIndexPath *)indexPath {
// Add the new object to the datasource and reload the row
[dataSourceArray insertObject:@"New" atIndex:indexPath.row];
[self.tableView beginUpdates];
[self.tableView insertRowsAtIndexPaths:@[indexPath] withRowAnimation:UITableViewRowAnimationNone];
[self.tableView endUpdates];
//setup temporary cell
UITableViewCell *fromCell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:nil];
[fromCell setBackgroundColor:[[self.tableView cellForRowAtIndexPath:indexPath] backgroundColor]];
//setup cell to animate to
UITableViewCell *toCell = [self.tableView cellForRowAtIndexPath:indexPath];
[toCell.textLabel setText:dataSourceArray[indexPath.row]];
//add fold animation to the cells create above
[MPFoldTransition transitionFromView:fromCell
toView:toCell
duration:0.4
style:MPFoldStyleUnfold
transitionAction:MPTransitionActionNone
completion:^(BOOL finished) {
[self.tableView reloadRowsAtIndexPaths:@[indexPath] withRowAnimation:UITableViewRowAnimationNone];
}];
}
About是一个将索引路径作为参数的函数。将您希望添加具有折叠转换的单元格的索引路径发送给它,它将在表上创建一个空白的临时单元格进行折叠,同时向下移动其余单元格。它并不完美,主要是因为我还没有找到一种方法来更改UITableViewRowAnimation
的持续时间,使其与折叠持续时间完美匹配
不管怎样,这都足以让你走了。希望这有帮助 “然而,本教程使用了一个UITableViewCell子类,我不能说”有什么特别的原因吗?原因是我需要立即销毁UIView(即重新激活它)@ACB我想我理论上可以使用一个非常定制的UITableViewCell,很抱歉,我对我的问题进行了编辑以反映这一变化