From 8a3acc68891fb734f7079798eb6cff0d03dd8f78 Mon Sep 17 00:00:00 2001 From: Shadowfacts Date: Wed, 28 Feb 2024 12:20:55 -0500 Subject: [PATCH] Use UIControl.performPrimaryAction instead of SPI on iOS 17.4 --- Tusker/Screens/Utilities/CustomAlertController.swift | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/Tusker/Screens/Utilities/CustomAlertController.swift b/Tusker/Screens/Utilities/CustomAlertController.swift index 1eae7bef..d74edd3e 100644 --- a/Tusker/Screens/Utilities/CustomAlertController.swift +++ b/Tusker/Screens/Utilities/CustomAlertController.swift @@ -332,9 +332,13 @@ class CustomAlertActionsView: UIControl { if action.handler == nil, case .menu(_) = action.style, let interaction = button.contextMenuInteraction { - let selector = NSSelectorFromString(["Location:", "At", "Menu", "present", "_"].reversed().joined()) - if interaction.responds(to: selector) { - interaction.perform(selector, with: recognizer.location(in: button)) + if #available(iOS 17.4, *) { + button.performPrimaryAction() + } else { + let selector = NSSelectorFromString(["Location:", "At", "Menu", "present", "_"].reversed().joined()) + if interaction.responds(to: selector) { + interaction.perform(selector, with: recognizer.location(in: button)) + } } } else { action.handler?()