How to tell when a UIMenu gets DISMISSED
Asked Answered
L

1

7

I have a UIButton with a UIMenu attached, I need to know when the UIMenu is dismissed (by tapping outside the UIMenu) so I can remove the button that the UIMenu is attached to.

I have seen there are notifications for UIMenuController, but that is different.

edit: Here's some additional info because this question was related to a different question.

I don't care when the UIMenu is called, I only care when it is dismissed

Lightening answered 12/11, 2021 at 21:10 Comment(3)
I understand your objection and I've reopened, but it's still really the same issue as #69710816 (in another guise).Empiricism
I had considered that, so I tried the implementation on that issue, but uideferredelement menu.uncached is only calling when the menu appears. not when its dismissed. But maybe im implementing it wrong.Lightening
I do not say the answer answers your question. I'm saying it's effectively the same question, namely where are the signals when the menu appears / disappears?Empiricism
G
3

You have to create custom button (for call menu) and override its method contextMenuInteraction(_:willEndFor:animator:). Add your action inside this method for removing the button that the UIMenu is attached to.

Gem answered 14/4, 2022 at 21:1 Comment(1)
But can we also differentiate between: a) User pressed in the background b) User selected an optionOkelley

© 2022 - 2025 — McMap. All rights reserved.