gpt4 book ai didi

iphone - UITableViewController:如果满足条件,则滑动以删除已启用

转载 作者:行者123 更新时间:2023-12-01 17:56:55 24 4
gpt4 key购买 nike

出于UIViewController重用的目的,我仅在满足条件的情况下才允许“滑动以删除”手势。有办法实现吗?

如果添加以下UITableViewController Delegate方法:

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

已启用“滑动以删除”功能,但在某些情况下我想禁用此手势无法区分

最佳答案

- (UITableViewCellEditingStyle)tableView:(UITableView *)aTableView
editingStyleForRowAtIndexPath:(NSIndexPath *)indexPath {
BOOL someCondition = // figure out whether you want swipe to be available
return (someCondition) ?
UITableViewCellEditingStyleDelete : UITableViewCellEditingStyleNone;
}

来自本书本节的结尾:

http://www.apeth.com/iOSBook/ch21.html#_deleting_table_items

关于iphone - UITableViewController:如果满足条件,则滑动以删除已启用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15813400/

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