Ios 未在UItableView Swift 4的滑动操作中显示标题

Ios 未在UItableView Swift 4的滑动操作中显示标题,ios,xcode,uitableview,swift3,Ios,Xcode,Uitableview,Swift3,我已经在UItableViewCell的前端设置了“添加到购物车”的操作。我已经设置了背景色、图片和标题。下面是我的代码 @available(iOS 11.0, *) func tableView(_ tableView: UITableView, leadingSwipeActionsConfigurationForRowAt indexPath: IndexPath) -> UISwipeActionsConfiguration? { let addToCart = UI

我已经在UItableViewCell的前端设置了“添加到购物车”的操作。我已经设置了背景色、图片和标题。下面是我的代码

 @available(iOS 11.0, *)
func tableView(_ tableView: UITableView, leadingSwipeActionsConfigurationForRowAt indexPath: IndexPath) -> UISwipeActionsConfiguration? {

    let addToCart = UIContextualAction(style: .normal, title: "Add to Cart") { (action, view, nil) in
        print("Added to cart")

    }
    addToCart.title = "Add to Cart"
    addToCart.backgroundColor = #colorLiteral(red: 0.2196078449, green: 0.007843137719, blue: 0.8549019694, alpha: 1)
    addToCart.image = UIImage(named: "cart")

    return UISwipeActionsConfiguration(actions: [addToCart])
}
以前的尝试:我没有使用
addToCart.title=“Add to Cart”
定义标题,但是在没有得到它之后,我已经设置了标题

我添加的图像大小为25*25,背景清晰,为.png格式

UIContextualAction支持文本图像。通过使用setImage:property设置图像,基本上可以在创建对象时删除标题。如果同时需要文本和图像,则需要使用嵌入文本创建图像

这是我的错误。除非表格视图单元格高度为91点,否则它不会同时显示图像和标题。
有关详细信息,请参见

UIContextualAction支持文本图像。通过使用setImage:property设置图像,基本上可以在创建对象时删除标题。如果同时需要文本和图像,则需要使用嵌入文本创建图像


这是我的错误。除非表格视图单元格高度为91点,否则它不会同时显示图像和标题。
如需了解更多信息,请尝试此操作


试试这个


如果我不想删除该行怎么办?!提问者需要在
UIContextualAction支持文本和图像中找到答案
如果我不想删除该行怎么办?!提问者需要在
UIContextualAction支持文本和图像中找到答案
你有解决方案吗?你有解决方案吗?
@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
        }