我想隐藏
moveRowAtIndexPath
上的(-) delete选项,以供编辑的
UITableView
使用。我看到
here
可以这样做,但那不是在Swift 2中。我找不到Swift 2的
return UITableViewCellEditingStyleNone
。有人能弄清楚吗?任何帮助都会很好。我在“苹果开发者指南”中也找不到任何东西。谢谢。
更新:我试图将
return UITableViewCellEditingStyle.None
放在我的
func tableView(tableView: UITableView, commitEditingStyle editingStyle: UITableViewCellEditingStyle, forRowAtIndexPath indexPath: NSIndexPath) {
部分,但它不允许这样做。它产生了一个错误
Unexpected non-void return value in voice function
。
第二次更新:使用了以下内容,它也可以禁用缩进:
// Allow only movement of cells not delete when 'edit' is pressed
func tableView(tableView: UITableView, editingStyleForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCellEditingStyle {
return UITableViewCellEditingStyle.None
// Don't indent when there is an edit happening (movement)
func tableView(tableView: UITableView, shouldIndentWhileEditingRowAtIndexPath indexPath: NSIndexPath) -> Bool {
return false
}
谢谢你的帮助!
在2中(经过测试的xcode 7.1):
func tableView(tableView: UITableView, editingStyleForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCellEditingStyle {
return .None;
}