简体   繁体   English

在 UITableView Swift 4 的主要滑动操作中不显示标题

[英]Not displaying the title in leading swipe actions for UITableView Swift 4

I have added two actions in tableview leading swipe action, but only the background is showing and title is not visible.我在表格视图中添加了两个动作,引导滑动动作,但只有背景显示,标题不可见。

func tableView(_ tableView: UITableView, leadingSwipeActionsConfigurationForRowAt indexPath: IndexPath) -> UISwipeActionsConfiguration? {
    let card = savedCards[indexPath.row]

//    if !card.isDefault{
        let makeDefault = UIContextualAction(style: .normal, title: "Make as Default") { (action, sourceView, completionHandler) in
            print("index path of default: \(indexPath)")

        }

        let closeAction = UIContextualAction(style: .normal, title:  "Mark as Read", handler: { (ac:UIContextualAction, view:UIView, success:(Bool) -> Void) in
            print("CloseAction ...")
            success(true)
        })
        closeAction.backgroundColor = .blue

        let swipeActionConfig = UISwipeActionsConfiguration(actions: [makeDefault,closeAction])
        swipeActionConfig.performsFirstActionWithFullSwipe = true
        return swipeActionConfig
  //  }

    return nil

}

在此处输入图像描述

func tableView(_ tableView: UITableView, leadingSwipeActionsConfigurationForRowAt indexPath: IndexPath) -> UISwipeActionsConfiguration? {

            let makeDefault = UIContextualAction(style: .normal, title: "Make as Default") { (action, sourceView, completionHandler) in
                print("index path of default: \(indexPath)")

            }

            let closeAction = UIContextualAction(style: .normal, title:  "Mark as Read", handler: { (ac:UIContextualAction, view:UIView, success:(Bool) -> Void) in
                print("CloseAction ...")
                success(true)
            })
            closeAction.backgroundColor = .blue

            let swipeActionConfig = UISwipeActionsConfiguration(actions: [makeDefault,closeAction])
            swipeActionConfig.performsFirstActionWithFullSwipe = true
            return swipeActionConfig

}

在此处输入图像描述

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

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