简体   繁体   中英

How to add Done Button to dismiss the Number Pad

I followed the tutorial:
http://www.neoos.ch/news/46-development/54-uikeyboardtypenumberpad-and-the-missing-return-key

to dismiss the number pad, this tutorial add the button as sub view to the number pad,

my problem is, in the same view I am using the text field to enter text also,so, how to differentiate the number field, and text field. so that I can hide the button view accordingly.

Yoy can use UITextFieldDelegate Protocol instead of NSNotifications, and inside methods textFieldDidBeginEditing: and textFieldDidEndEditing: check which field is being used. Something like this:

- (void) textFieldDidBeginEditing:(UITextField *)textField { 
if (textField == self.passwordField) {
  // add subview...
}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM