When text is selected/marked in my app this window pops up with different options if the user would want to copy/cut out etc, but I want this window not to be able to pop up at all. Anyone knows how to achieve this?
Asked
Active
Viewed 516 times
0
-
Does this answer your question? [How to disable pasting in a TextField in Swift?](https://stackoverflow.com/questions/29596043/how-to-disable-pasting-in-a-textfield-in-swift) – Raja Kishan Aug 21 '21 at 10:32
1 Answers
3
You must create a subclass of your UITexField
or UITextView
(or UILabel
) depending on which one you want to disable the UIMenu
.
Then override:
func canPerformAction(_ action: Selector,
withSender sender: Any?) -> Bool
And return no for the selectors you want to disable.
If you prefer to disable selection of text in a UITextView
, you can disable the selection behavior.

Andrea
- 26,120
- 10
- 85
- 131