ios - 在 UIKit 中,当用户滑动删除表格视图单元格时,如何显示确认对话框?
问题描述
是否有相当于 SwiftUI 的 ConfirmDialog (_:isPresented:titleVisibility:actions:)的 UIKit ?
解决方案
也许UIAlertController。您必须在 UIViewController 上显示它。例如使用 actionSheet 样式。
let alert = UIAlertController(
title: "Title",
message: "Message",
preferredStyle: .actionSheet
)
alert.addAction(UIAlertAction(
title: "Delete",
style: .destructive,
handler: { _ in
// delete action
}))
alert.addAction(UIAlertAction(
title: "Cancel",
style: .cancel,
handler: { _ in
// cancel action
}))
present(alert,
animated: true,
completion: nil
)
推荐阅读
- c++ - Win32 c ++将RGB颜色迭代到WM_PAINT中的窗口
- python - 如何在 python3 中安装 itertools 模块?
- python - 如何忽略 pandas read_csv 中的备用换行符?
- javascript - Jest fn undefined 当用作对象属性时
- c++ - 如何在动态编程中将递归值存储在我的地图中
- python - Python:如何根据选择的单一颜色更改图像的调色板?
- c# - FluentMigrator - how does it know which migration to execute
- reactjs - React Native:XCode:构建失败并出现错误“EMFILE:打开的文件太多,请观看”
- sql-server - 将 Datagrip 与 SqlServer 一起使用:链接服务器和自动完成
- python - Selenium Python3 Bruteforce Login 带有 2 个单独的文本文件。错误