refresh textfield without exiting view

Discussion in 'iOS Programming' started by StefanDevil, Aug 21, 2010.

  1. macrumors member

    Jul 31, 2010

    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 :)
  2. Moderator


    Staff Member

    Sep 2, 2004
    The Centennial State
    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.
  3. thread starter macrumors member

    Jul 31, 2010
    hi, the clear button is not the textfield itself clear button, which only clear its particular row. i implemented a "clear all textfield button"

    	UIAlertView *alert = [[UIAlertView alloc] initWithTitle:
    						  @"Delete All?"
    										  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 = @" ";

  4. macrumors 604

    Aug 9, 2009
    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.
  5. thread starter macrumors member

    Jul 31, 2010
    hey is the button index problem! thanks for your help :)

Share This Page