3

When we enter character in textfield then it is enabling the return key. But in our requirement we need to enable the return key when length is more than 5. But now as soon as we enter character it is enabling the return key. Do we need to customize the keyboard or is there any other solution available. Thanks in advance.

Pang
  • 9,564
  • 146
  • 81
  • 122
ankit kumar
  • 55
  • 1
  • 3
  • `enablesReturnKeyAutomatically` is what enables the key when there is data in the textfield. Perhaps you can check if the length is greater than or equal to 5 and set it to YES.. or Less than 5 and set it to NO.. Maybe in `UITextField shouldChangeCharactersInRange` delegate. – Brandon Aug 26 '15 at 12:31
  • 1
    I have tried this but it is not working. – ankit kumar Aug 26 '15 at 12:50

1 Answers1

-2

Well I think you should handle it in the UITextField delegate :

- (BOOL) textFieldShouldReturn:(UITextField*) textField {
     return textField.text.length > 0;
 }
byJeevan
  • 3,728
  • 3
  • 37
  • 60
Suhaiyl
  • 1,071
  • 9
  • 17
  • or you can go with this approach : http://stackoverflow.com/questions/788323/disable-enable-return-key-in-uitextfield – Suhaiyl Aug 26 '15 at 12:30