In iOS 26 there is a new way of displaying action sheets from the buttons that triggers them. I figured out that in SwiftUI you can just set the confirmationDialog view modifier on the button that triggers it.
However, I can't find a way to get this behavior in UIKit when a UIButton triggers an alert. Has anyone got this work?
The behavior is mentioned briefly in the "Get to know the new design system" session.
For additional context:
@objc func showConfirmationDialog(_ sender: UIButton) {
let alert = UIAlertController(
title: "Are you sure?",
message: "Do you want to proceed?",
preferredStyle: .actionSheet
)
alert.addAction(UIAlertAction(title: "Cancel", style: .default,handler: nil))
alert.addAction(UIAlertAction(title: "Confirm", style: .destructive, handler: { _ in
}))
alert.popoverPresentationController?.sourceItem = sender
present(alert, animated: true, completion: nil)
}
Here when the sourceItem is set
alert.popoverPresentationController?.sourceItem = sender
the popover’s arrow points to the specified item