Saturday, August 11, 2012

Getting the Value of a UITextField as keystrokes are entered?


On Typing in one Uitextfield can be displayed in another uitextfield 

UITextField  * text1=[[UITextField alloc]initWithFrame:CGRectMake(250, 380, 200, 50)];
    text1.userInteractionEnabled=NO;
    text1.textAlignment=UITextAlignmentLeft;
    text1.font=[UIFont fontWithName:FontNormal size:20];
    text1.keyboardType=UIKeyboardTypeDefault;
    text1.backgroundColor=[UIColor whiteColor];
    [self.view addSubview:text1];
    [text1 release];

[text1 addTarget:self action:@selector(updateLabelUsingContentsOfTextField:) forControlEvents:UIControlEventEditingChanged];

- (void)updateLabelUsingContentsOfTextField:(id)sender {

  UiLabel  *greetingLabel.text = [NSString stringWithFormat:@"Hello %@", ((UITextField *)sender).text];

}

No comments:

Post a Comment