开发者

how do I copy UITextField data into a UILabel

开发者 https://www.devze.com 2022-12-27 19:04 出处:网络
I have a textfield and a label. When you touch the textfield, the keyboard appears In IB, the textfield\'s properties are

I have a textfield and a label.

When you touch the textfield, the keyboard appears

In IB, the textfield's properties are

Keyboard: ASCII Capable Return Key: Do开发者_运维知识库ne

I wired the IBOutlet to the label and the textfield.

How do I get the keyboard to go away when I'm done entering text. How do I get to copy the text to the UIlabel?

thanks


If you push the DONE Button, the UITextField sends a -textFieldDidEndEdititing: method to its delegate, which should be your controller instance.

This method simply moves the editor focus off the UITextField and thus makes the keyboard disappear. Then put the new values into the UILabel:

-(void)textFieldDidEndEditing:(UITextField *)textField {
    [textField resignFirstResponder];
    label.text = textField.text;
}
0

精彩评论

暂无评论...
验证码 换一张
取 消