【问题标题】:In UIKit, how do you present a confirmation dialog when the user is swiping to delete a table view cell?在 UIKit 中,当用户滑动删除表格视图单元格时,如何显示确认对话框?
【发布时间】:2021-10-01 11:41:36
【问题描述】:

有没有相当于 SwiftUI 的 confirmationDialog(_:isPresented:titleVisibility:actions:) 的 UIKit?

【问题讨论】:

    标签: ios swift uitableview uikit


    【解决方案1】:

    也许是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
    )
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2011-11-11
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2016-01-20
      • 1970-01-01
      • 1970-01-01
      • 2019-06-26
      相关资源
      最近更新 更多