我在 iOS
中显示 UIAlertController
,并且 iPhone and iPad
执行相同的代码 . 所以任何人都可以帮助这个 . 正如我谷歌但没有找到任何证明这一点的事情 . 以下是我使用过的代码: -
let alert = UIAlertController(title: title, message: message, preferredStyle: UIAlertController.Style.alert)
let okAction = UIAlertAction(title: "Button.Ok".localizedValue(), style: .destructive, handler: { _ in
})
let cancelAction = UIAlertAction(title: "Button.Cancel".localizedValue(), style: .default, handler: { _ in
alert.dismiss(animated: true, completion: nil)
})
alert.accessibilityLabel = self.viewModel.deleteUserConfirmationAccessibilityId()
alert.addAction(okAction)
alert.addAction(cancelAction)
self.present(alert, animated: true, completion: nil)
所以问题是这样的: - iPhone:当为iPhone中的UIAlertController进行自动化测试时,“删除所有已保存的”文本来自DOM结构的UIAView . iPad:在iPad中对UIAlertController进行自动化测试时,“删除所有已保存的”文本属于DOM结构的UIView .
那么为什么UIAlertController结构会出现差异,因为iPhone iPad会显示相同代码的UIView和iPhone UIAView .
1 回答
你必须为ipad添加popoverpresentation控制器 . 请看下面的代码