如何在UITableView中使单元格可移动但不可删除? [英] How can I make a cell movable but not deletable in a UITableView?

查看:104
本文介绍了如何在UITableView中使单元格可移动但不可删除?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

你好,我的问题很简单。我有一个带有几个单元格的 UITableView 。其中一些可以删除(但不一定都是全部),但所有这些都可以移动。

Hello, my problem is quite simple. I have a UITableView with a couple of cells. Some of them can be deleted (but not necessarily all of them), but all of them can be movable.

我不明白如何通过iOS SDK实现这一点。使用 tableView的组合:canMoveRowAtIndexPath: tableView:canEditRowAtIndexPath:我只能将单元格设置为可删除,并最终可移动,但反之亦然。我想将单元格设置为可移动但不一定可删除。这可能吗?

I do not understand how to realize this through the iOS SDK. Using a combination of tableView:canMoveRowAtIndexPath: and tableView:canEditRowAtIndexPath: I am only able to set a cell as deletable, and eventually movable, but not vice versa. I would like to set a cell as movable but not necessarily deletable. Is this possible?

推荐答案

可移动:



Movable:

-(BOOL)tableView:(UITableView *)tableView canMoveRowAtIndexPath:(NSIndexPath *)indexPath         
{
    return YES;
}



不可删除:



Non-Deletable:

- (UITableViewCellEditingStyle)tableView:(UITableView *)tableView editingStyleForRowAtIndexPath:(NSIndexPath *)indexPath 
{
    return UITableViewCellEditingStyleNone;
}

这篇关于如何在UITableView中使单元格可移动但不可删除?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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