开发者

how do I copy UITextField data into a UILabel

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

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜