How to add done button on keyboard on top of keyboard in IOS?

前端 未结 8 1563
悲哀的现实
悲哀的现实 2020-12-08 04:04

I want to add the Done button on the top of keyboard on right side in iOS for a textView.Please tell me how can i do that?

I w

8条回答
  •  独厮守ぢ
    2020-12-08 04:50

    The answer from Ramis that allows the keyboard accessory view to be created using the Storyboard is a great strategy. It is 2017 after all! (Sorry, but I do not have enough points to upvote you.)

    Let me add a little to the answer (to keep within the SO rules). I have a view with multiple textFields. After implementing each of Ramis' steps I attached the accessoryView to all of the textFields in this way:

    -(void)textFieldDidBeginEditing:(UITextField *)textField
    {
    _activeTextField = textField;
    [_activeTextField setInputAccessoryView:_iboKeyboardTools];
    }
    

    So easy compared with implementing all this in code! Just build the accessory view in Storyboard- and attach it again and again!

提交回复
热议问题