Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/ios/111.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Ios 如何在EditActionsErrorwat操作中安装图标_Ios_Swift_Uitableview - Fatal编程技术网

Ios 如何在EditActionsErrorwat操作中安装图标

Ios 如何在EditActionsErrorwat操作中安装图标,ios,swift,uitableview,Ios,Swift,Uitableview,如何在活动中心设置图标? 我正在使用这段代码,它添加了3个操作,colurCode完成/撤消&删除在单元格上滑动时,所有这些操作几乎占据了单元格的所有空间。我想添加自定义图标而不是文本,但当我添加它时,它不会显示在我的滑块中,可能它没有集中在动作中,我该怎么做 override func tableView(_ tableView: UITableView, editActionsForRowAt indexPath: IndexPath) -> [UITableViewRowAction

如何在活动中心设置图标? 我正在使用这段代码,它添加了3个操作,
colurCode
完成/撤消
&
删除
在单元格上滑动时,所有这些操作几乎占据了单元格的所有空间。我想添加自定义图标而不是文本,但当我添加它时,它不会显示在我的滑块中,可能它没有集中在动作中,我该怎么做

override func tableView(_ tableView: UITableView, editActionsForRowAt indexPath: IndexPath) -> [UITableViewRowAction]? {


    let delete = UITableViewRowAction(style: .normal, title: "Delete") { (action, indexPath) in
        let task = self.tasks[indexPath.row]
        let context = (UIApplication.shared.delegate as! AppDelegate).persistentContainer.viewContext
        self.tasks.remove(at: indexPath.row)
        context.delete(task)
        (UIApplication.shared.delegate as! AppDelegate).saveContext()
        tableView.deleteRows(at: [indexPath], with: .automatic)
        //tableView.reloadData()

    }

    let colorCode = UITableViewRowAction(style: .normal, title: "Color") { (action, indexPath) in


        let popOverVC = UIStoryboard(name: "Main", bundle: nil).instantiateViewController(withIdentifier: "popOver")as! popUpViewController
        self.addChildViewController(popOverVC)
        popOverVC.view.frame = self.view.frame
        self.view.addSubview(popOverVC.view)
        popOverVC.didMove(toParentViewController: self)
        tableView.setEditing(false, animated: true)
    }



    let cell=tableView.cellForRow(at: indexPath) as! CustomCell

    if cell.checkTest.on{
        let undone = UITableViewRowAction(style: .normal, title: "Undo") { (action, indexPath) in
            let task = self.tasks[indexPath.row]
            task.checkDone = "off"
            (UIApplication.shared.delegate as! AppDelegate).saveContext()
            // Update Cell
            cell.stopanimate()
            tableView.setEditing(false, animated: true)
        }
        undone.backgroundColor = UIColor.lightGray
        delete.backgroundColor = UIColor(patternImage: UIImage(named: "red dot")!)
        return [delete, undone, colorCode]

    }
    else{
        let done = UITableViewRowAction(style: .normal, title: "Done") { (action, indexPath) in
            let task = self.tasks[indexPath.row]
            task.checkDone = "on"
            (UIApplication.shared.delegate as! AppDelegate).saveContext()

            let cell=tableView.cellForRow(at: indexPath) as! CustomCell 
            cell.makeanimate()                
            tableView.setEditing(false, animated: true) 
        } 
        done.backgroundColor = UIColor.lightGray
        delete.backgroundColor = UIColor(patternImage: UIImage(named: "tick1")!)
        return [delete, done, colorCode]


    }


}

您可以简单地在
行操作标题中添加一些空格,就像下面的
“Delete”

override func tableView(_ tableView: UITableView, editActionsForRowAt indexPath: IndexPath) -> [UITableViewRowAction]? {

let delete = UITableViewRowAction(style: .normal, title: "      Delete     ") { (action, indexPath) in

}
return [delete]
}

我的行中还有另外两个动作,所以它们都有很大的宽度。我可以不设置每个标题的自定义宽度吗?其他标题是什么?@Joe我编辑了我的问题:)考虑使用图标而不是标题。@Joe我使用了这个
delete.backgroundColor=UIColor(patternImage:UIImage(名为:“tick1”)!),但它似乎没有显示出来
@Joe你知道图标是如何放置在动作中的吗,比如什么尺寸合适?