How to implement the buttons above the keyboard? (For example: the application "Notes")

Found only mention Accessory Input View . enter image description here

  • and what do you need to do? to get suggestions? This is in my opinion in the phone settings. perhaps it is necessary for the view to which you want suggestions to enable auto-correct. - Max Mikheyenko
  • @MaxMikheyenko no, I'm not talking about suggestions, but about a button tied to the keyboard. - user4478196
  • Then the link above seems to be the appropriate answer - Max Mikheyenko

1 answer 1

It is inputAccessoryView that is needed here. Here is a small example from life.

 UIToolbar *tbKbd = [[UIToolbar alloc] initWithFrame:CGRectMake(0.0, 0.0, 320.0, 44.0)]; UIBarButtonItem *btDone = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemDone target:self action:@selector(yourHandler)]; UIBarButtonItem *spacer = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemFlexibleSpace target:nil action:nil] tbKbd.items = @[spacer, btDone]; textField.inputAccessoryView = tbKbd; 

The result is a neat socket with a button above the keyboard. spacer needed only to push the button to the right edge of the keyboard. The button will be labeled Done, but you can do with any label, with an icon — anything, any UIBarButtonItem . You can even do your transparent UIView instead of the toolbar, as you wish :)