在UIKit中,当用户滑动删除表格视图单元格时,你如何呈现一个确认对话框?



是否有一个UIKit等同于SwiftUI的confirmationDialog(_: ispresent:titleVisibility:actions:)?

可能是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
)

最新更新