Fix NSRangeException when typing in a TextField with formatted text

Fixes #1792
This commit is contained in:
Rossen Hristov
2016-03-18 15:27:28 +02:00
parent 7458880f28
commit c492d894d5

View File

@@ -82,8 +82,10 @@ class UITextFieldDelegateImpl extends NSObject implements UITextFieldDelegate {
owner._onPropertyChangedFromNative(TextBase.textProperty, replacementString);
}
else {
let newText = NSString.alloc().initWithString(textField.text).stringByReplacingCharactersInRangeWithString(range, replacementString);
owner._onPropertyChangedFromNative(TextBase.textProperty, newText);
if (range.location <= textField.text.length) {
let newText = NSString.alloc().initWithString(textField.text).stringByReplacingCharactersInRangeWithString(range, replacementString);
owner._onPropertyChangedFromNative(TextBase.textProperty, newText);
}
}
}
}