TextField uses the placeholder property, but it also sets the Text property in the code, so Viewcontroller displays both placeholder and text text.
This problem has made me completely collapsed. According to the truth, when the text length is 0 o'clock placeholder text display, text text length is not 0 o'clock placeholder should be hidden?
And I've never had this problem under normal circumstances. Later, I created a new project, and I couldn't reproduce the problem with many attempts.
Although the cause of the problem has not been found yet. But Google's work is not a bit. A question has been raised on StackOverflow, and may be associated with this article:
"Before the IOS 6 SDK (for example, the 5.1 SDK), changing the Text property of the text field, whether in code or not, would result in uitextfieldtextdidchangenotification
Notification is generated. In the iOS 6 SDK, if you change the value of text in code, the UITEXTFIELDTEXTDIDCHANGENOTIFICATION notification will not be generated. ”
I was inspired by this. That being the case, then whenever I modify the Text property (encoding mode), manually post a uitextfieldtextdidchangenotification
What about the notice? For example:
Tfphone.text = "1255"
Nsnotificationcenter.defaultcenter (). Postnotificationname (Uitextfieldtextdidchangenotification, object: Self.tfphone)
Transmission Door
http://blog.csdn.net/kmyhy/article/details/49585695
Placeholder resolving issues that placeholder and text text in Uitextfield display simultaneously