get UITextField Tag in Custom Methods

//yourviewcontroller.h

@interface ViewController : UIViewController    {
 int tag;
}

//yourviewcontroller.m

- (void)viewDidLoad    {
    [super viewDidLoad];    
    tag = 0;
}
- (BOOL)textFieldShouldBeginEditing:(UITextField *)textField// return NO to disallow editing.
{    
    tag = textField.tag;        
    return YES;
}
- (IBAction)cancelNumberPad:(UITextField*)textField {        
    NSLog(@"The user is typing in text field %d",tag);        

}

- (IBAction)doneWithNumberPad:(UITextField*)textField {       

    NSLog(@"The user is typing in text field %d",tag);
}

Leave a Comment