swift - swift中tableview单元格滑动图标之间的空间
问题描述
在我的代码中,当我滑动 tableview 单元格时,图标看起来像是彼此重叠。但我想要这些图标之间的一些空间。我的代码:-
func tableView(_ tableView: UITableView, trailingSwipeActionsConfigurationForRowAt indexPath: IndexPath) -> UISwipeActionsConfiguration?{
let inboxAction = UIContextualAction(style: .normal, title: "", handler: { (action,view,completionHandler ) in
//do stuff
let storyboard = UIStoryboard(name: "Swipe", bundle: nil)
let selectParentProfile = storyboard.instantiateViewController(withIdentifier: "InboxViewController") as? InboxViewController
self.navigationController?.pushViewController(selectParentProfile!, animated: true)
completionHandler(true)
})
// create action for the delete button
let cgImageXq = UIGraphicsImageRenderer(size: CGSize(width: 110, height: 120)).image { _ in
UIImage(named: "inbox")?.draw(in: CGRect(x: 0, y: 0, width: 110, height: 120))
}
inboxAction.image = cgImageXq
//create action for the block button
let filesAction = UIContextualAction(style: .normal, title: "", handler: { (action,view,completionHandler ) in
//do stuff
let storyboard = UIStoryboard(name: "Swipe", bundle: nil)
let selectParentProfile = storyboard.instantiateViewController(withIdentifier: "PdfFilesViewController") as? PdfFilesViewController
self.navigationController?.pushViewController(selectParentProfile!, animated: true)
completionHandler(true)
})
let cgImageY = UIGraphicsImageRenderer(size: CGSize(width: 100, height: 120)).image { _ in
UIImage(named: "eval-form")?.draw(in: CGRect(x: 0, y: 0, width: 100, height: 120))
}
filesAction.image = cgImageY
//create action for the block button
let browserAction = UIContextualAction(style: .normal, title: "", handler: { (action,view,completionHandler ) in
//do stuff
let storyBoard = UIStoryboard(name: "Form", bundle: nil)
let folderTableViewController = storyBoard.instantiateViewController(identifier: "FormForPdfViewController")
self.navigationController?.pushViewController(folderTableViewController, animated: true)
})
let cgImageZ = UIGraphicsImageRenderer(size: CGSize(width: 100, height: 120)).image { _ in
UIImage(named: "pdf-files")?.draw(in: CGRect(x: 0, y: 0, width: 100, height: 120))
}
browserAction.image = cgImageZ
// Add both the delete button and add button here
let confrigation = UISwipeActionsConfiguration(actions: [browserAction, filesAction, inboxAction])
confrigation.performsFirstActionWithFullSwipe = false
return confrigation
}
并且通过单击图标我可以导航到另一个视图控制器。但是当我回到这个视图控制器时,仍然显示图标选项,但我需要在导航期间关闭滑动选项。
解决方案
推荐阅读
- typescript - TypeScript Compiler API 如何设置 Lib?
- python - 从 pandas 的列表列中,访问列表中的每个字符串以删除数字和句点
- kubernetes - 为什么 k8s 示例限制 PodSecurityPolicy 不限制 RunAsGroup?
- javascript - 如何在滚动时触发多个css动画
- r - 发布后出现由放置data.frame引起的错误。我应该把它放在哪里?
- c# - 将装箱的 BigInteger 转换为其他类型
- java - 如何从 postgres 中的 JSONB 列中获取前 10 个元素
- javascript - 从辅助源加载 JS 和 CSS 脚本
- kubernetes - Ingress 重写到另一个 Ingress
- scala - Spark / scala如何从前一列中减去当前列的值?