Hi folks, I'm struggling with an issue on MacCatalyst. I'm using a dynamic menu that is supposed to show the current state of a setting (state = .on / .off). The UIDeferredMenuElement works great on iOS, the closure is called on each display of the (context) menu.
On MacCatalyst however - where I use the menu as a submenu in the main menu - the closure is called only once on first menu display. The system seems to show a cached menu item even though I'm using UIDeferredMenuElement.uncached.
Here's the relevant code:
func getMenuElement() {
let element = UIDeferredMenuElement.uncached { completion in
let modeString = mode.myLocalizedDescription
let trackingMode = <current setting>
let mode = <menu item setting option>
let state = trackingMode == mode ? .on : .off
let action = UIAction(title: modeString,
image: <image>,
state: state) { _ in
viewController.setUserTrackingMode(mode)
}
completion([action])
}
return element
}
Any ideas how to trick the system into generating the dynamic menu item on each menu display?