【发布时间】:2021-10-01 11:41:36
【问题描述】:
有没有相当于 SwiftUI 的 confirmationDialog(_:isPresented:titleVisibility:actions:) 的 UIKit?
【问题讨论】:
标签: ios swift uitableview uikit
有没有相当于 SwiftUI 的 confirmationDialog(_:isPresented:titleVisibility:actions:) 的 UIKit?
【问题讨论】:
标签: ios swift uitableview 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
)
【讨论】: