如何在UITextField中键入时执行操作?
First set your UITextField's delegate to your class.
If you want to call an event as soon as user types anything implement this method,
- (BOOL)textField:(UITextField *)textField shouldChangeCharactersInRange:(NSRange)range replacementString:(NSString *)string{
NSLog(@"call your method");
[self goMethodCall];
return YES;
}
If you want somthing other than this, you have few more delegates.
There are few delegates that are invoked automatically...
– textFieldShouldBeginEditing:
– textFieldDidBeginEditing:
– textFieldShouldEndEditing:
– textFieldDidEndEditing:
– textField:shouldChangeCharactersInRange:replacementString:
– textFieldShouldClear:
– textFieldShouldReturn:
In any of the method call your action.
Find suitable for you.. here
There are several ways to be notified when the text of a text field has changed:
UITextField
delegate method textField:shouldChangeCharactersInRange:replacementString:
UITextFieldTextDidChangeNotification
notification. UIControlEventEditingChanged
control event on the text field.
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.