I'm displaying an action sheet on my iPad using the struture below. Only the last two actions are appearing. The first one, with the style of .cancel, isn't being displayed. Any idea what could be going on?
DispatchQueue.main.async {
var message = ...
let alert = UIAlertController(title: nil, message: message, preferredStyle: .actionSheet)
message = ...
alert.addAction(title: message, style: .cancel) { }
message = ...
alert.addAction(title: message, style: .destructive) { }
message = ...
alert.addAction(title: message, style: .default) { }
if let p = alert.popoverPresentationController {
p.sourceView = rootVC.view
p.sourceRect = CGRect(x: rootVC.view.center.x, y: rootVC.view.center.y, width: 10, height: 10)
}
rootVC.present(alert, animated: true)
}extension UIAlertController {
func addAction(title: String?, style: UIAlertActionStyle, handler: ((UIAlertAction) -> Void)? = nil) {
addAction(UIAlertAction(title: title, style: style, handler: handler))
}
}