UITextField question

Discussion in 'iOS Programming' started by pinsrw, Nov 8, 2010.

  1. pinsrw macrumors regular

    Joined:
    May 30, 2010
    #1
    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.
     
  2. Sykte macrumors regular

    Joined:
    Aug 26, 2010
    #2
    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
    
     
  3. pinsrw, Nov 8, 2010
    Last edited: Nov 8, 2010

    pinsrw thread starter macrumors regular

    Joined:
    May 30, 2010

Share This Page