Not displaying the title in Swipe actions for UItableView Swift 4

前端 未结 2 703
北恋
北恋 2021-01-15 19:56

I have set an action for \"add to cart\" at leading side of the UItableViewCell. I have set background colour, its image and title. below\'s my code.

 @avail         


        
2条回答
  •  一生所求
    2021-01-15 20:21

    Try this

    Add swipe to delete UITableViewCell

    @available(iOS 11.0, *)    
    func tableView(_ tableView: UITableView, trailingSwipeActionsConfigurationForRowAt indexPath: IndexPath) -> UISwipeActionsConfiguration? {
                let action =  UIContextualAction(style: .normal, title: "", handler: { (action,view,completionHandler ) in
                    //do stuff
                    completionHandler(true)
                    let data:NSDictionary = self.conversations[indexPath.row] as! NSDictionary
                    print(data)
                    let alert:UIAlertController = UIAlertController(title: "", message: "are you sure want to delete ?", preferredStyle: .alert)
    
                    alert.addAction(UIAlertAction(title: "CANCEL", style: UIAlertActionStyle.cancel, handler: { (action) in
                    }))
                    self.present(alert, animated: true, completion: nil)
                })
                action.image = UIImage(named: "")
                action.backgroundColor = UIColor(red: 0/255, green: 148/255, blue: 204/255, alpha: 1.0)
                let confrigation = UISwipeActionsConfiguration(actions: [action])
    
                return confrigation
            } 
    

提交回复
热议问题