skip to Main Content

I’m having trouble removing this tick when text is selected, I’ve tried this:

class CustomUITextField: UITextField {
   open override func canPerformAction(_ action: Selector, withSender sender: Any?) -> Bool {
      return false
   }
}

which removes stuff like copy, paste etc, but doesn’t seem to remove this new iOS 16 feature. Thankful for any help 🙂

enter image description here

2

Answers


  1. you can try:

        - (void)buildMenuWithBuilder:(id<UIMenuBuilder>)builder API_AVAILABLE(ios(13.0))  {
            if (@available(iOS 16.0, *)) {
                [builder removeMenuForIdentifier:UIMenuLookup];
            }
            [super buildMenuWithBuilder:builder];
        }
    
    Login or Signup to reply.
  2. Add the following code to your custom subclass:

    @available(iOS 13.0, *)
    override func buildMenu(with builder: UIMenuBuilder) {
        builder.remove(menu: .lookup)
    
        super.buildMenu(with: builder)
    }
    
    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search