Multiple UIALERTView, pop-ups more than code

Discussion in 'iOS Programming' started by RashiMahajan, Nov 11, 2010.

  1. RashiMahajan, Nov 11, 2010
    Last edited by a moderator: Nov 11, 2010

    RashiMahajan macrumors newbie

    Apr 17, 2009
    In my app, i m posting some data to the server, in return expecting some acknowledgment msgs. Accordingly displaying the pop-up on UI for informing the user for success or Failure.

    When i post the data for more than two times to server, i should get two pop-up but here i get three pop-ups. At very first pop - up appears & disappears then again pop appears, now t wait for user click after that other appears.

    I am using simple code in loop..

    if([nss_value isEqualToString:@"0"]) 
    { [self showAlert:@"Success" :nil]; } 
    else { [self showAlert:@"Failure" :nil]; } 
    -(void)showAlert:(NSString *)nss_title:(NSString *)nss_msg
    UIAlertView *uialv_userConfirmation =[[UIAlertView alloc]initWithTitle:nss_title message:nss_msg delegate:self cancelButtonTitle:nil otherButtonTitles:@"Ok",nil];
     [uialv_userConfirmation show]; 
    [uialv_userConfirmation release]; 
    Can anybody help me ....... :(
  2. Sykte macrumors regular

    Aug 26, 2010

    You will need to post more code if you want help. The current context doesn't tell the entire story, specifically what\where the if statements are.

    Side Note:
    May I ask why you're comparing a string of 0? You may want to name your method parameters. (You are not truly naming your parameters as much as making the methods more descriptive)

    -(void)showAlert:(NSString *)nss_title:(NSString *)nss_msg
    could be 
    -(void)showAlertWithTitle:(NSString *)nss_title andMessage:(NSString *)nss_msg

    This will help you while coding and help others read your code if you have a question.
  3. ianray macrumors 6502

    Jun 22, 2010
    Not three pop-ups, but rather this kind of sequence:
    1. Show popup #1
    2. Show popup #2
    3. Click to dismiss
    4. Show popup #1 again

    If you want a maximum of one pop-up, then use an instance variable and programmatically dismiss any existing UIAlertView before instantiating a new one. Good luck :)

Share This Page