不,这不是系统错误。您似乎可能遇到与第三方库相关的问题。我建议使用本机 iOS 内置功能 UIAlertController 来显示警报,如提供的代码示例所示:
@objc func showAlert() {
let alertController = UIAlertController(title: "Alert Title", message: "This is a sample alert.", preferredStyle: .alert)
// Add a text field to the alert
alertController.addTextField { (textField) in
textField.placeholder = "Additional Text"
}
let okAction = UIAlertAction(title: "OK", style: .default) { (action) in
// Access the text field's text here if needed
if let textField = alertController.textFields?.first {
print("Additional Text: \(textField.text ?? "")")
}
}
alertController.addAction(okAction)
let cancelAction = UIAlertAction(title: "Cancel", style: .cancel, handler: nil)
alertController.addAction(cancelAction)
present(alertController, animated: true, completion: nil)
}
// Override to allow rotation to landscape mode
override var supportedInterfaceOrientations: UIInterfaceOrientationMask {
return .all
}
// Override to specify the initial interface orientation
override var preferredInterfaceOrientationForPresentation: UIInterfaceOrientation {
return .landscapeLeft
}
如果问题仍然存在,查看更多代码或接收有关您所面临问题的其他信息将会很有帮助。