首页 > 解决方案 > 显示带有延迟标题和消息的 actionSheet 样式的警报

问题描述

从 iOS 13 开始,我的带有 actionSheet 样式的警报以“延迟”的标题和消息显示。

这些是 Apple 的发行说明

我已经研究了很多,但找不到如何让它像 iOS 13.1 之前那样工作,在 iOS 13.1 之前,标题和消息是在操作按钮的同时呈现的。

这是创建警报并显示它的方法:

    private func showRemoveConfirmationAlert() {
        let alert = UIAlertController(
            title: "Remove device?".localized(), 
            message: "Are sure you want to remove this device from your account?\nMake sure to unpair your device before removing it. This action cannot be undone.".localized(), 
            preferredStyle: .actionSheet
        )

        alert.addAction(UIAlertAction(title: "Remove".localized(), style: .destructive, handler: { _ in
            AnalyticsHelper.logRemoveDeviceConfirmedTapped()
            self.viewModel?.removeFromAccount()
        }))
        alert.addAction(UIAlertAction(title: "Cancel".localized(), style: .cancel, handler: { _ in
            AnalyticsHelper.logCancelTapped()
        }))

        if let popoverController = alert.popoverPresentationController {
            popoverController.sourceView = self.view
        }

        self.present(alert, animated: true)
    }

这就是它的样子:

显示带有延迟标题和消息的警报

任何帮助,将不胜感激!提前致谢。

标签: iosswiftios13uialertcontrollerpresentviewcontroller

解决方案


这是从 iOS 13 开始的默认行为。如果要立即渲染,请将动画更改为 false

self.present(alert, animated: false, completion : nil)

推荐阅读