UITextField теряют событие фокуса

От документы Python на os.walk():

# Delete everything reachable from the directory named in 'top',
# assuming there are no symbolic links.
# CAUTION:  This is dangerous!  For example, if top == '/', it
# could delete all your disk files.
import os
for root, dirs, files in os.walk(top, topdown=False):
    for name in files:
        os.remove(os.path.join(root, name))
    for name in dirs:
        os.rmdir(os.path.join(root, name))

22
задан Salim 28 February 2016 в 12:50
поделиться

2 ответа

I believe you need to designate your view as a UITextField delegate like so:

@interface MyCustomUIView : UIView <UITextFieldDelegate> { 

As an added bonus, this is how you get the keyboard to go away when they press the "done" or return buttons, depending on how you have set that property:

- (BOOL)textFieldShouldReturn:(UITextField *)theTextField {
  //This line dismisses the keyboard.       
  [theTextField resignFirstResponder];
  //Your view manipulation here if you moved the view up due to the keyboard etc.       
  return YES;
}
14
ответ дан 29 November 2019 в 04:17
поделиться

Возможно, вам придется создать подкласс UITextField и переопределить resignFirstResponder . resignFirstResponder будет вызываться, когда текстовое поле теряет фокус.

2
ответ дан 29 November 2019 в 04:17
поделиться