开发者

Enable keyboard return key

开发者 https://www.devze.com 2023-02-14 05:06 出处:网络
I would like to enable the keyboard return key only when some uitextfields are not empty. I read this question

I would like to enable the keyboard return key only when some uitextfields are not empty. I read this question How to disable/enab开发者_运维百科le the return key in a UITextField?

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


Following thing will enable/disable return key automatically.

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

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


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

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

More detailed answer here.


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

0

精彩评论

暂无评论...
验证码 换一张
取 消