0

I have a text field that is editable by the user and it contains some example text saying "Tap here to enter details". I would like the text box to clear when the user taps it so that the user does not have to delete my example before inputting their message. Is there an easy way of doing this. The only thing I can think of is to make a separate view controller that it links to when the text box is touched buut this seems an awful way round something which I would have thought is rather simple. All help greatly appreciated.

Thank you in advanced.

4

2 回答 2

4

在此处输入图像描述UITextField 有一个属性 clearsOnBeginEditing

于 2012-07-14T15:32:44.170 回答
0

我知道你已经得到了答案,但是使用 UITextField 的委托方法还有一个替代方法textFieldDidBeginEditing:——

     - (void)textFieldDidBeginEditing:(UITextField *)textField {

textField.text = @"";

}
于 2012-07-14T16:11:06.163 回答