7

New in iOS 9 on iPad, there's a toolbar (known as the Shortcut bar) placed above the keyboard that provides undo, redo, and paste buttons. It appears while using the system keyboard or third-party keyboards, but it doesn't appear above the emoji keyboard. I don't want this toolbar visible when my custom keyboard extension is in use, as my keyboard is similar to the emoji keyboard. (Note that I'm talking about a custom keyboard extension that can be used in any app, not the keyboard shown when a text field becomes first responder in your own app.) So how can one remove it?

Jordan H
  • 52,571
  • 37
  • 201
  • 351

1 Answers1

7

You can remove it using this

- (void)textFieldDidBeginEditing:(UITextField*)textField
{
    if(SYSTEM_VERSION_GREATER_THAN(@"8.4")){
        UITextInputAssistantItem* item = [textField inputAssistantItem];
        item.leadingBarButtonGroups = @[];
        item.trailingBarButtonGroups = @[];
    }
}

and of course you need to define the macro SYSTEM_VERSION_GREATER_THAN in header to check for the version since this code will crash your app on iOS 8

#define SYSTEM_VERSION_GREATER_THAN(v)              ([[[UIDevice currentDevice] systemVersion] compare:v options:NSNumericSearch] == NSOrderedDescending)

have fun :)

Mohamed Emad Hegab
  • 2,665
  • 6
  • 39
  • 64
  • That's for hiding it in your own app (and you additionally need to disable autocorrect to get it to hide). My question is how to hide it above your custom keyboard which can be used throughout the system. – Jordan H Sep 17 '15 at 14:41
  • 1
    Thank you for this answer, though! I have the problem in my own app and couldn't figure out how to disable those until I found this answer – BarrettJ Oct 12 '15 at 13:08
  • This will crash on 8.4.1. Instead use `if ([textField respondsToSelector:@selector(inputAssistantItem)]) {` – Wise Shepherd Mar 14 '16 at 19:06