开发者

Delete characters from textfields,iphone

I have textfield and having a number "1234567890" now i have button, on tapping it, it should delete the the number from last. like as in keyboard. but one time tap, should delete one int at a time. I dont want to delete whole number at once, it should ju开发者_StackOverflowst delete a single int, on every single click.

How can i implement it. Suggestion are always appreciated


- (IBAction) deleteCharacter : (id)sender     
{
    if ([textField.text length] > 0)
    {
    textField.text = [textField.text substringToIndex:[textField.text length] - 1];
    }
}


Get the textField string and remove the last character from that.Again show the new string in the textField

NSString *str=urTextField.text;
urTextField.text=[str substringToIndex:([str length]-1)];
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜