简体   繁体   English

UITableView强制从左向左滑动以删除不起作用

[英]UITableView Force Right-to-Left swipe to delete not work

I have uiviewcontroller with uitableview 我有uiviewcontroller和uitableview

and swipe to delete work fine but 并滑动以删除工作正常,但

when I set uitableview semantic to force right-to-left the swipe to delete not even shown in the tableview 当我设置uitableview语义以强制从右向左滑动以删除时甚至未在tableview中显示

在此处输入图片说明

 classViewController:UIViewController,UITableViewDelegate,UITableViewDataSource {

    var yourArray : [Type] = []

    override func viewDidLoad() {
        super.viewDidLoad()
        tablView.delegate = self
        tablView.dataSource = self
    }


    func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
           return yourArray.count
    }

    func tableView(_ tableView: UITableView, canEditRowAt indexPath: IndexPath) -> Bool {
           return true
    }


   func tableView(_ tableView: UITableView, commit editingStyle: UITableViewCellEditingStyle, forRowAt indexPath: IndexPath) {

      if editingStyle == .delete{
         tableView.beginUpdates()
               yourArray.remove(at: indexPath.row)
                  tableView.endUpdates()
                  tableView.reloadData()
       }
   }
}

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

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