UIMainMenuSystem - disable elements

Hi, I am trying to implement the UIMainMenuSystem for showing the menu bar in my iPad app in iOS26. I would like to be able to disable some elements when a particular UIViewController is displayed on the screen, and I can't figure out the best way to do this. I tried overriding the 'validateCommand' method in my view controller, but it doesn't seem to invoke the validation for menu items that are in the main menu.

Any tips on how to do this?

validateCommand is only called on a responder (like a view controller) when that responder is the target for the action. UIKit will disable any menu items automatically if it can't find a target in the responder chain for that action.

Is the action performable on a very high-level responder, like UIApplication or the AppDelegate? That suggests you want that action to be performable always, so you can't have it be disabled for a particular view controller. If you need the action to be performable on a per-view-controller basis, you should implement the action at the view controller level (so if the view controller that should disable the action is up, then UIKit won't be able to find a responder/view controller that can perform the action).

UIMainMenuSystem - disable elements
 
 
Q