refresh textfield without exiting view

Discussion in 'iPhone/iPad Programming' started by StefanDevil, Aug 21, 2010.

  1. macrumors member

    Joined:
    Jul 31, 2010
    #1
    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 :)
     
  2. Moderator

    dejo

    Staff Member

    Joined:
    Sep 2, 2004
    Location:
    The Centennial State
    #2
    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

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

    Code:
    -(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
     
  4. macrumors 603

    Joined:
    Aug 9, 2009
    #4
    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

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

Share This Page