Reputation: 17
I can't find tutorial that does this. I have...
UIbutton
UItext.text
I want to make my own KEYBOARD user interface without iphone keyboard. I want to press the UIbutton(keyboard "delete" key or backspace) from text. Not ease the whole thing like UIText.text = @""
. I've seen programmers give the wrong code. I'm looking for something like Visual Basic Sendkeys {Delete}
. How do I do this on iphone button? http://gigaom.com/apple/iphone-os-where-the-delete-key-belongs/
For example:
Text1
Text<=
Tex<=
Upvotes: 1
Views: 697
Reputation: 259
if ([textField.text length] != 0) {
textField.text = [textField.text substringToIndex:[textField.text length]-1];
}
Upvotes: 1
Reputation: 13371
Implement the following method to delete the last character.
- (NSString *)deleteLastChar:(NSString *)str {
if (![str length]) return @"";
return [str substringToIndex:[str length]-1];
}
You can then use that on your text field's text property e.g:
textField.text = [self deleteLastChar:textField.text];
Upvotes: 3