objective-c - 添加/删除带有动画的 UITableViewCell?

我知道这听起来可能是个愚蠢的问题,但我到处都看过。我该怎么做?

我知道如何使用 swype-to-delete 方法执行此操作,但我如何在该功能之外执行此操作?

请发布一些代码示例。

谢谢!
库尔顿

最佳答案

[self.tableView beginUpdates];
[self.tableView insertRowsAtIndexPaths:insertIndexPaths withRowAnimation:UITableViewRowAnimationFade];
[self.tableView deleteRowsAtIndexPaths:deleteIndexPaths withRowAnimation:UITableViewRowAnimationFade];
[self.tableView endUpdates];

insertIndexPaths 是要插入到表中的 NSIndexPaths 数组。

deleteIndexPaths 是要从表中删除的 NSIndexPaths 数组。

索引路径的示例数组格式:

NSArray *insertIndexPaths = [[NSArray alloc] initWithObjects:
        [NSIndexPath indexPathForRow:0 inSection:0],
        [NSIndexPath indexPathForRow:1 inSection:0],
        [NSIndexPath indexPathForRow:2 inSection:0],
        nil];

https://stackoverflow.com/questions/5560602/

相关文章:

iphone - 何时在 iPhone 上使用 UIView 与 UIViewController?

objective-c - Objective-C 中的属性和实例变量

ios - 子类化时混合objective-c和swift

ios - 协议(protocol)和委托(delegate)之间的区别?

ios - info.plist中的 "Application Requires iPhone En

iphone - UIScrollView - 显示滚动条

ios - 有没有办法在用户已经在 iOS 上拒绝相机访问权限后向他们询问?

ios - IOHIDFamily 的神秘控制台错误

objective-c - 获取最顶层的 UIViewController

ios - 以编程方式获取应用程序支持文件夹的路径