How do I programmatically set the Return Key for a particular UITextField?

前端 未结 4 2003
情书的邮戳
情书的邮戳 2020-12-14 14:46

I can\'t believe that this question hasn\'t been asked yet, but I have been unable to find it so that is my assumption.

I have created custom UITableViewCel

相关标签:
4条回答
  • 2020-12-14 15:19

    In swift 4, the following code can be used for replacing the "Return button" on keyboard with "search button" or "done button":

    yourTextField.returnKeyType = UIReturnKeyType.search
    yourTextField.returnKeyType = UIReturnKeyType.done
    
    0 讨论(0)
  • 2020-12-14 15:24

    It can also be done by setting property in .xib file. You just have to set Return Key property of UITextField to Next under Attribute Inspector.

    0 讨论(0)
  • 2020-12-14 15:34

    you have to invoke [textView reloadInputViews]; after setting the return key type to update the keyboard return key appearance immediately.

    DO IT AS FLLOW:

    textView.returnKeyType = UIReturnKeyDone; [textView reloadInputViews];

    0 讨论(0)
  • 2020-12-14 15:41

    For the first UITextField, Read THIS tutorial on how to create a button on a Keyboard. You can learn the logic from there and use a Next button instead of Done button.

       //if you just want to make it appear NEXT//
    
        textField.returnKeyType = UIReturnKeyNext;
    

    And for the second UITextField, use...

       // for DONE //
    
        textField.returnKeyType = UIReturnKeyDone;
    

    You can in general create and rename the button to anything, and make sure you give the right IBAction on the event that that button is pressed. In case you do create your own custom button, look at the tutorial above to learn about placing it in the right coordinates and stuff.

    0 讨论(0)
提交回复
热议问题