0

I have uiviewcontroller with 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

enter image description here

Bosoud
  • 158
  • 4
  • 24

1 Answers1

0
 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()
       }
   }
}