简体   繁体   English

有没有办法在iOS 7中的iOS 6之类的表格视图调用中向左和向右滑动以显示删除按钮。

[英]Is there any way to show delete button on Swipe left and Right on tableview call like iOS 6 in iOS 7.

I am showing delete button on the UITableView cell on Swipe left and right. 我在向左和向右滑动的UITableView单元上显示删除按钮。

It is working fine on iOS 6. But on iOS 7 instead of swipe delete tableview cell scroll to left and a delete button appears on the right most. 它在iOS 6上运行良好。但是在iOS 7上,您可以向左滚动而不是滑动删除表视图单元格,并在最右边显示一个删除按钮。

Is there any way to show delete button by Swipe left and Right on tableviewcell like iOS 6 in iOS 7 as I don't want iOS 7 default delete behavior. 有什么办法可以通过在iOS 7中的iOS 6之类的tableviewcell上左右滑动来显示删除按钮,因为我不希望iOS 7默认删除行为。

Swift 3 Try Swift 3试试

override func tableView(_ tableView: UITableView, canEditRowAt indexPath: IndexPath) -> Bool {

    return true
}

override func tableView(_ tableView: UITableView, commit editingStyle: UITableViewCellEditingStyle, forRowAt indexPath: IndexPath) {
    if editingStyle == .delete {
        objects.remove(at: indexPath.row)
        tableView.deleteRows(at: [indexPath], with: .fade)
    } 
}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM