简体   繁体   English

在 UIKit 中,如何在用户滑动删除表格视图单元格时显示确认对话框?

[英]In UIKit, how do you present a confirmation dialog when the user is swiping to delete a table view cell?

是否有等效于 SwiftUI 的 ConfirmationDialog (_:isPresented:titleVisibility:actions:)的 UIKit ?

Maybe UIAlertController .也许UIAlertController You must present it on a UIViewController.您必须将它呈现在 UIViewController 上。 Use actionSheet style for example.例如使用 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
)

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

相关问题 滑动以删除UITableView中的单元格时如何禁用UITextView? - How do I disable a UITextView when swiping to delete a cell in a UITableView? 当用户单击单元格时,如何从表详细视图中的数组加载视频? - How do you load video from an array in table detail view when the user clicks on the cell? iOS:在滑动表格视图单元格时是否可以覆盖show-red-delete-button-method? - iOS: Is it possible to override the show-red-delete-button-method when swiping a table view cell? 滑动单元格时如何隐藏其他滑动单元格动作 - How do you hide other swipe cell actions when swiping the cell 滑动原型表视图单元时显示视图 - Reveal view when swiping a prototype table view cell 自定义表视图单元不滑动 - Custom Table View Cell Not Swiping 当用户未完全滑动以删除表格视图单元格时,如何禁用/启用编辑按钮? - How do i disable/enable edit button when user doesn't fully swipe to delete table view cell? 滑动删除单元格时断言失败错误 - Assertion failure error when swiping to delete cell 如何删除表视图中的单元格 - how to delete the cell in table view 滑动表格视图单元格后,我们需要多次点击垃圾桶按钮才能将其删除 - after swiping the table view cell, we need to tap the trash button more than once to get it delete
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM