Does UITextInteraction have a way to dismiss the edit menu?

If I use UIEditMenuInteraction to present an edit menu, it has a dismissMenu method that I can call to remove the menu when necessary.

When I use UITextInteraction, I get an edit menu automatically that is normally presented and dismissed at appropriate times. But sometimes I want to dismiss the menu myself, and I can't find a way to do that. Am I missing something? I was hoping to find that UITextInteraction inherited from UIEditMenuInteraction, or had some other way to access the underlying menu in order to dismiss it. But it seems that the menu must be a private part of the UITextInteraction implementation.

The particular case that I need to deal with is when I call resignFirstResponder. This seems to cause the keyboard to close and the insertion point and any selection to be hidden, but if an edit menu was shown then it remains visible (a ghost!). If anyone knows of an alternative to resignFirstResponder that will make UITextInteraction tidy up properly, that would also be useful to know.

Thanks for any suggestions!

Replies

Answering my own question....

When you add a UITextInteraction, a UIEditMenuInteraction gets added automatically. So it's possible to iterate through the view's interactions and find the menu interaction using isKindOfClass, and call dismissMenu on that.

It's a bit of a hack, but I've done much worse and it seems to work.