表视图在Swift中提交编辑样式

App*_*Kid 0 iphone uitableview ios swift

我有这个代码,我想将其转换为快速代码.

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

    return UITableViewCellEditingStyleNone;
}
Run Code Online (Sandbox Code Playgroud)

我默认获得删除编辑样式,我想要无风格.提前致谢.!!

rob*_*off 6

您可以通过命令单击UITableViewDelegateSwift源文件或操场中的标识符来获取方法的正确声明.这使得Xcode向您展示了Swift-ified版本UITableView.h.在那里,您可以搜索editingStyleForRowAtIndexPath以找到确切的方法签名.一旦你有了,其余的很容易:

func tableView(tableView: UITableView!, editingStyleForRowAtIndexPath indexPath: NSIndexPath!) -> UITableViewCellEditingStyle {
    return .None
}
Run Code Online (Sandbox Code Playgroud)

请注意,由于声明的方法返回类型,Swift推断它NoneUITableViewCellEditingStyle枚举的成员.