title: UIAlertView getting called Twice in iPhone
body: <blockquote>
    <p><strong>Possible Duplicate:</strong><br>
    <a href="https://stackoverflow.com/questions/7688329/uilongpressgesturerecognizer-on-uitableviewcell-double-call">UILongPressGestureRecognizer on UITableViewCell - double call</a>  </p>
  </blockquote>
  
  
  
  <p>I am new to iPhone,</p>
  
  <p>I am displaying Alert when Button is pressed long, but when i press button long my alert view  gets called again.</p>
  
  <p>Here is my code snippet,</p>
  
  <pre><code>- (IBAction)longPressDetected:(UIGestureRecognizer *)gestureRecognizer {
  
      //Gets text of Button.
      UIButton *btn = (UIButton *)[gestureRecognizer view];
      BtnText= [btn titleForState:UIControlStateNormal];
      NSLog(@"longPressDetected");
  
      UIAlertView* alert_view = [[UIAlertView alloc]
                                 initWithTitle: @"Are you sure want to Delete ?" message:nil delegate: self 
                                 cancelButtonTitle: @"Yes" otherButtonTitles: @"No", nil];
      [alert_view show];
      [alert_view release];
  }
  
  - (void)alertView:(UIAlertView *)alertView clickedButtonAtIndex:(NSInteger)buttonIndex
  { 
      if (buttonIndex==0) {
  
          [self ReloadView];
           [alertView dismissWithClickedButtonIndex:0 animated:TRUE];
      }
      else{
          [alertView dismissWithClickedButtonIndex:1 animated:TRUE];
      }
  }
  </code></pre>
  
  <p><strong>Any help will be appreciated.</strong></p>
  
  <p><strong>EDIT:</strong></p>
  
  <pre><code>  -(void)viewWillAppear:(BOOL)animated
     {
           for(int i=0;i&lt;10i++)
              {
  
                  if(i!=0)
                  {
                      if (i%4==0) 
                      {                    
                          ypos+=180;
                          xpos=30;
                      }
                      else
                      {
                          xpos+=200;
                      }
                  }
  
  
                  button = [UIButton buttonWithType:UIButtonTypeCustom];
                  button.frame = CGRectMake(xpos, ypos, 120,130);
                  [button setBackgroundImage:[UIImage imageNamed:@"ibook2.png"] forState:UIControlStateNormal];
                  [button setTitle:[NSString stringWithFormat:@"%@", [Downloadedepubs objectAtIndex:i]] forState:UIControlStateNormal];
                  [button addTarget:self action:@selector(buttonClicked:) forControlEvents:UIControlEventTouchUpInside];
  
                   LongPress = [[UILongPressGestureRecognizer alloc] init];
                  [LongPress addTarget:self action:@selector(longPressDetected:)];
                   LongPress.delegate = (id&lt;UIGestureRecognizerDelegate&gt;)self;
                  [button addGestureRecognizer:LongPress];
                  [self.view addSubview:button];
                  [LongPress release];
  
        } 
  
     }
  </code></pre>