I have an IPad apllication in which I need to make a number pad type keyboard in my view. With a textfield and 9 numbers.and a back press button. I had achieved this with 9 buttons and a text field.In each of the button action I am appending that digit to the text field value like this:
[number setText:[number.text stringByAppendingString:@"9"]];
Now I need to change the background of the button when textfield.length equall to 9. Otherwise the same. For that i include a check in my each button actions like this.
if ([number.text length]==9)
{
[button setBackgroundImage:[UIImage imageNamed:@"active.png"] forState:UIControlStateNormal];
}
else
{
[button setBackgroundImage:[UIImage imageNamed:@"inactive.png"] forState:UIControlStateNormal];
}
before upending the next i am checking this.but it is changing the background at 9 digits only if include [number.text length]==8.and in the back trace button i am removing the last appended digit by
if ( [number.text length] > 0)
{
number.text = [number.text substringToIndex:[number.text length] - 1];
}
Here I am checking the digits after the operation.then it is taking the correct length.
can any body help me?
You will have to check same on each button click.
And this is your
deleteButtonClickedMethodNo need to use
substringToIndex:.