【发布时间】:2019-12-29 05:04:50
【问题描述】:
从 iOS 13 开始,我的带有 actionSheet 样式的警报以“延迟”的标题和消息显示。
这些是 Apple 的 release notes。
我已经研究了很多,但找不到如何让它像 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)
}
这就是它的样子:
任何帮助将不胜感激!提前致谢。
【问题讨论】:
-
您提供的发行说明链接适用于 SwiftUI 应用程序。
-
您从哪里拨打
showRemoveConfirmationAlert? -
@MidhunMP 单击左侧的 NavigationBarButton 时,会显示一个带有 2 个按钮的警报,即删除设备和取消。单击删除设备会调用
showRemoveConfirmationAlert。第一个警报仅包含 2 个操作按钮,因此不存在动画问题。
标签: ios swift ios13 uialertcontroller presentviewcontroller