开发者

Delete characters from textfields,iphone

开发者 https://www.devze.com 2023-04-08 17:54 出处:网络
I have textfield and having a number \"1234567890\" now i have button, on tapping it, it should delete the the number from last.

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

精彩评论

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