Uitextview on how to add a similar to the Uitextfield placeholder, in fact, add a uilabel on Uitextview, and then realize
-(BOOL) TextView: (uitextview *) TextView shouldchangetextinrange: (nsrange) range Replacementtext: (nsstring *) Text This proxy method is possible.
The specific implementation is as follows:
[OBJC]View Plaincopy< param name= "allowfullscreen" value= "false" >
- -(BOOL) TextView: ( Uitextview *) TextView shouldchangetextinrange:(nsrange) range replacementtext:( NSString *) Text
- {
- if (![ Text isequaltostring:@ ""]) {
- _label1. Hidden = YES;
- }
- if ([Text isequaltostring:@ "] && range. location = = 0 && range. length = = 1) {
- _label1. Hidden = NO;
- }
- return YES;
- }
The description is as follows:
(1) _label1 is added to the Uitextview on the Uilabel
(2) [Text isequaltostring:@ ""] means the BACKSPACE key is entered
(3) Range.location = = 0 && Range.length = = 1 indicates the first character entered
The effect is as follows:
the original http://blog.csdn.net/chchong1234/article/details/24646719 thanks to bloggers for sharing ~