I\'d like to place some fixed text inside an UITextField, but before the insert point, sort of like this:
...where \"towaards\"
I guess you can do that by implementing UITextFieldDelegate. There is one method – textField:shouldChangeCharactersInRange:replacementString:.
In this method you can check each and every character which is entering by user (even backspace). So first you implement change in another NSString
object then validate with your condition.
Check whether new string passes through your validation then replace the old string with new string, otherwise leave it as it is.
For example, check new string starts with your string or not. You can use this:
[myString hasPrefix:@"He went"];
Here in the same method you can also do one more thing, when user taps on UITextField
check if @"(towaards)"
string is there in textField then remove that text by code.
Hope this is what you want.
Just set the text property of the label to @"He went (towaards) and when editing is started change it to @"He went "
I don't think you can put noneditable and editable text in the same UITextField.
What about putting a UILabel with the noneditable text right beside the UITextField ?