用动画添加/删除UITableViewCell? [英] Add/Delete UITableViewCell with animation?

查看:93
本文介绍了用动画添加/删除UITableViewCell?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我知道这可能听起来像一个愚蠢的问题,但我已经看过每一个地方。我怎么能这样做?

I know this might sound like a dumb question, but I have looked every where. How can I do this?

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

I know how to do this with a swype-to-delete method, but how cam I do it outside that function?

请发布一些代码示例。

谢谢!
Coulton

Thanks!
Coulton

推荐答案

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

insertIndexPaths 是一个NSIndexPaths数组插入你的桌子。

insertIndexPaths is an array of NSIndexPaths to be inserted to your table.

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

deleteIndexPaths is a array of NSIndexPaths to be deleted from your table.

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

Example array format for index paths :

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

这篇关于用动画添加/删除UITableViewCell?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆