Sefran2
Sefran2

Reputation: 3588

Enable keyboard return key

I would like to enable the keyboard return key only when some uitextfields are not empty. I read this question How to disable/enable the return key in a UITextField?

Is this the only way? Is it true this could cause Apple to reject the app?

Upvotes: 2

Views: 5789

Answers (3)

Paul B
Paul B

Reputation: 5115

This is not a public API, so use it on your own risk.

textField.setValue(true/false, forKeyPath: "inputDelegate.returnKeyEnabled")

More detailed answer here.

Upvotes: 0

Gaurav Taywade
Gaurav Taywade

Reputation: 8347

Following thing will enable/disable return key automatically.

  • (BOOL)textFieldShouldBeginEditing:(UITextField *)textField {

     textfield.enablesReturnKeyAutomatically = YES;
    
    // your code here
    
      return YES;  }
    

Upvotes: 3

GendoIkari
GendoIkari

Reputation: 11914

You can use the textFieldShouldReturn: method to prevent the return key from returning.

http://developer.apple.com/library/ios/#documentation/uikit/reference/UITextFieldDelegate_Protocol/UITextFieldDelegate/UITextFieldDelegate.html

Upvotes: -1

Related Questions