I user custom UITextView and need to hide keyboard on return click. I need to catch 'ShouldChangeTextInRange' what has textview, I don't know why but method is not called. here is code of for my text view :
public class PlaceholderTextView : UITextView
{
public PlaceholderTextView ()
{
Initialize ();
}
public PlaceholderTextView (CGRect frame)
: base (frame)
{
Initialize ();
}
public PlaceholderTextView (IntPtr handle)
: base (handle)
{
Initialize ();
}
void Initialize ()
{
Text = Placeholder;
ShouldBeginEditing = t => {
if (Text == Placeholder)
Text = string.Empty;
return true;
};
ShouldEndEditing = t => {
if (string.IsNullOrEmpty (Text))
Text = Placeholder;
return true;
};
}
public override bool ShouldChangeTextInRange (UITextRange inRange, string replacementText)
{
if (Text.Equals ("\n")) {
this.EndEditing (true);
return false;
} else {
return true;
}
}
}