【问题标题】:Delete functionality similar to iOS delete messages [closed]类似于iOS删除消息的删除功能[关闭]
【发布时间】:2012-05-24 01:57:18
【问题描述】:

我在 UITableView 中有一个要删除的项目列表,有没有办法重用与 iPhone 中删除消息类似的删除功能?

【问题讨论】:

标签: ios ios5 imessage


【解决方案1】:

您将需要实现一些 UITableViewDelegate 方法,例如:

- (UITableViewCellEditingStyle)tableView:(UITableView *)tableView editingStyleForRowAtIndexPath:(NSIndexPath *)indexPath

- (void)tableView:(UITableView *)tableView commitEditingStyle:(UITableViewCellEditingStyle)editingStyle forRowAtIndexPath:(NSIndexPath *)indexPath

要提供编辑和删除单元格的默认功能,您需要在导航栏中包含编辑按钮,例如:

[[self navigationItem] setLeftBarButtonItem:[self editButtonItem]];

这应该满足您正在寻找的大多数“默认”实现,当然还有一些修改来环绕您的代码:)

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2019-11-07
    • 1970-01-01
    • 2022-08-18
    • 2012-12-23
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多