PDA

View Full Version : refresh textfield without exiting view




StefanDevil
Aug 21, 2010, 09:11 AM
hi

I have four textfield in a view. now when user clicks the clear button, all four textfield will be clear. after button is press, i set the all the textfield = @" ", how can i refresh the view so that this change is shown, with out exiting the view.

tHks :)



dejo
Aug 21, 2010, 10:07 AM
how can i refresh the view so that this change is shown, with out exiting the view.
You shouldn't have to exit the view. Such a change should be almost immediate, assuming you're not blocking the main run loop. Perhaps there is an issue with your update code. Let's see it.

StefanDevil
Aug 21, 2010, 10:42 AM
hi, the clear button is not the textfield itself clear button, which only clear its particular row. i implemented a "clear all textfield button"


-(IBAction)ClearAll
{
UIAlertView *alert = [[UIAlertView alloc] initWithTitle:
@"Delete All?"
message:nil
delegate:self
cancelButtonTitle:@"Cancel"
otherButtonTitles:@"OK", nil
];
[alert show];
[alert release];

}

- (void)alertView:(UIAlertView *)alertView clickedButtonAtIndex:(NSInteger)buttonIndex {
// the user clicked one of the OK/Cancel buttons
if (buttonIndex == 0)
{
field1.text = @" ";
field2.text = @" ";
field3.text = @" ";
field4.text = @" ";


}
}




thks

chown33
Aug 21, 2010, 11:17 AM
If you don't see a change in the textfields, do some basic debugging.

1. NSLog the button-index received by alertView:clickedButtonAtIndex:.

2. Confirm that button-index 0 is the correct value for clearing the fields, and isn't the button-index for Cancel.

Instead of assuming your code works, assume it doesn't work. Then add statements like NSLog() or assertions that can show you whether it's doing what it should.

StefanDevil
Aug 21, 2010, 12:23 PM
If you don't see a change in the textfields, do some basic debugging.

1. NSLog the button-index received by alertView:clickedButtonAtIndex:.

2. Confirm that button-index 0 is the correct value for clearing the fields, and isn't the button-index for Cancel.

Instead of assuming your code works, assume it doesn't work. Then add statements like NSLog() or assertions that can show you whether it's doing what it should.

hey is the button index problem! thanks for your help :)