Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

pinsrw

macrumors regular
Original poster
May 30, 2010
194
0
Hi all,

I have a question about responding to user input:
I've found I'm able to respond to the end-of-editing situation using callbacks for ValueChanged and Editing Did End, but I'm curious: How do I respond to individual keystrokes?

Thanks.
 
Hi all,

I have a question about responding to user input:
I've found I'm able to respond to the end-of-editing situation using callbacks for ValueChanged and Editing Did End, but I'm curious: How do I respond to individual keystrokes?

Thanks.

UITextField Delegate Protocol Ref:
http://developer.apple.com/library/...html#//apple_ref/occ/intf/UITextFieldDelegate



Code:
textField:shouldChangeCharactersInRange:replacementString:
Asks the delegate if the specified text should be changed. 

- (BOOL)textField:(UITextField *)textField shouldChangeCharactersInRange:(NSRange)range replacementString:(NSString *)string
Parameters
textField
The text field containing the text.

range
The range of characters to be replaced 

string
The replacement string. 

Return Value
YES if the specified text range should be replaced; otherwise, NO to keep the old text. 

Discussion
The text field calls this method whenever the user types a new character in the text field or deletes an existing character.

Availability
Available in iOS 2.0 and later.
Declared In
UITextField.h
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.