UITableView添加单元格animation
任何一个可以帮助我与UITableView
animation问题?
默认情况下,我们有用于删除单元格和重新sortingUITableView
单元格的animation。
我们可以有animation添加单元格,如果是的话,怎么做。
我已经检查了Three20 ,并没有得到如何twitter
已经做了MyProfile> ReTweets下的表扩展animation。
要使用UITableView
的现有animation,不用Three20 frameowrk,
来尝试它。
你可以使用下面的UITableView方法:
- (void)insertRowsAtIndexPaths:(NSArray *)indexPaths withRowAnimation:(UITableViewRowAnimation)animation
self.dataSource是一个可变数组,而您的表只有一个部分的示例:
[self.dataSource addObject:@"New Item"]; NSIndexPath *newIndexPath = [NSIndexPath indexPathForRow:[self.dataSource count]-1 inSection:0]; [tableView insertRowsAtIndexPaths:[NSArray arrayWithObject:newIndexPath] withRowAnimation:UITableViewRowAnimationFade];
注意:从数据源计数中减去1,因为NSIndexPath是零索引。
迅速
示例数组是表视图的数据源
var myArray = ["Cow", "Camel", "Sheep", "Goat"]
以下将在表视图的顶部添加一个animation行。
// add message to current array myArray.insert("Horse", atIndex: 0) // insert row in table let indexPath = NSIndexPath(forRow: 0, inSection: 0) tableView.insertRowsAtIndexPaths([indexPath], withRowAnimation: UITableViewRowAnimation.Fade)
多个更新
如果您需要执行多次插入和/或删除,请使用beginUpdates()
和endUpdates()
它们包围。
tableView.beginUpdates() tableView.insertRowsAtIndexPaths([addIndexPath1, addIndexPath2, ...], withRowAnimation: .Fade) tableView.deleteRowsAtIndexPaths([deleteIndexPath1, deleteIndexPath2, ...], withRowAnimation: .Fade) tableView.endUpdates()
进一步阅读
- 文档
使用reloadRowsAtIndexPaths:indexPath
tableView.beginUpdates() [tableView reloadRowsAtIndexPaths:indexPath withRowAnimation:UITableViewRowAnimationAutomatic]; tableView.endUpdates()
我希望这能帮到您..
- 如何在ios中使用关键帧animation时设置animation曲线?
- 如何animationUINavigationBar中的button更改?
- layoutAttributesForSupplementaryViewOfKind:atIndexPath:传入不正确的indexPath
- 如何使用CoreAnimationanimation像钟倒计时一样的圆
- 如何使UINavigationBar中的UISearchBar仅使用块animation调整左边距?
- iOS的粒子animation
- UIImageViewcaching图像?
- 使用核心animation对图像进行sorting,接收内存警告
- 核心animation中的圆形箭头蒙版的长度的animation