I have one text field.
Below function is attached to an UI event “editing changed” from txtfield’s IB.
The function is recursive as obvious I am changing the textfield so it will call
again and again is there any thing , I can stop the function after calling it once.
So,I want to stop this looping function..
-(IBAction) testEvents:(id) sender
{
txtEditAmount.text=[txtEditAmount.text substringToIndex:([txtEditAmount.text length]-1)];
}
Rather than using that event callback, try implementing the
UITextFieldDelegatemethodtextFieldDidEndEditing:, like so:So it will cut off the last character only when the user stops editing the field. Depends what you’re trying to do though, I guess. If you’re trying to backspace whatever they type, for example, a password field which stays blank but still captures the characters the user types, instead implement the protocol method
textField:shouldChangeCharactersInRange:replacementString:like this: