gpt4 book ai didi

iphone - 如何处理用户在 TableView 的 setEditing 中点击 "delete button "?

转载 作者:太空狗 更新时间:2023-10-30 03:50:58 24 4
gpt4 key购买 nike

我像这样在 table 上添加了一个 editButton:

    self.navigationItem.leftBarButtonItem = self.editButtonItem;

并且,有一个 setEditing 方法:

- (void) setEditing:(BOOL)editing animated:(BOOL)animated {
[super setEditing:editing animated:animated];
[self.watchListDetailTableView setEditing:editing animated:animated];
if (editing) {
// you might disable other widgets here... (optional)
} else {
// re-enable disabled widgets (optional)
}
}

点击编辑后,我可以有一个叉号和删除按钮,我应该用什么方法来处理删除按钮的点击?谢谢你。

最佳答案

应该是这样的:

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

More Info Here

When users tap the insertion (green plus) control or Delete button associated with a UITableViewCell object in the table view, the table view sends this message to the data source, asking it to commit the change. (If the user taps the deletion (red minus) control, the table view then displays the Delete button to get confirmation.) The data source commits the insertion or deletion by invoking the UITableView methods insertRowsAtIndexPaths:withRowAnimation: or deleteRowsAtIndexPaths:withRowAnimation:, as appropriate.

关于iphone - 如何处理用户在 TableView 的 setEditing 中点击 "delete button "?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/3633277/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com