title: Button Clicked Event was triggered Twice or More in iOS
body: <p>I added a button on a section and wrote clicked event</p>
  
  <pre><code>var refreshCacheSettings = new CustomButtonSection ("GeneralSettingsView_RefreshCache_Button_Title".t());
  
              refreshCacheSettings.ButtonClicked += async (sender, e) =&gt; {
  
                  Console.WriteLine ("Clicked...");
                  var btn = (UIButton)sender;
                  btn.Enabled=false;
                  btn.UserInteractionEnabled =false;
  
                  var answer= await AlertUtil.CreateMessageYesNo("GeneralSettingsView_RefreshCache_Question_Title".t(),"GeneralSettingsView_RefreshCache_Question_Message".t());
  
                  if(!answer)
                  {
                      ShowLoadingScreen();
                      await Task.Run(()=&gt; RefreshFormFieldSettings());
                  }
  
  
                  btn.Enabled=true;
                  btn.UserInteractionEnabled =true;
  
              };
  </code></pre>
  
  <p>and here is custom button section class</p>
  
  <pre><code>public class CustomButtonSection : RootElement
  {
      string _btnText;
      public event EventHandler ButtonClicked;
      public CustomButtonSection (string btnText):base ("")
      {
          base.MakeViewController ();
          _btnText = btnText;
  
      }
  
  
      protected override UIViewController MakeViewController ()
      {
          var vc = (UITableViewController) base.MakeViewController();
  
          vc.TableView.BackgroundView = null;
          vc.View.BackgroundColor = UIColor.White; //or whatever color you like
          return vc;
      }
  
      public override void Selected (DialogViewController dvc, UITableView tableView, NSIndexPath path)
      {
          base.Deselected (dvc, tableView, path);
      }
  
      public override UITableViewCell GetCell (UITableView tv)
      {
  
          var cell = tv.DequeueReusableCell ("CustomCell") as CustomButtonCell;
          if (cell == null)
              cell = new CustomButtonCell (new NSString("CustomCell"));
  
          cell.Accessory = UITableViewCellAccessory.None;
          cell.SelectionStyle = UITableViewCellSelectionStyle.None;
          cell.UpdateCell (_btnText);
          cell.btn.TouchUpInside += (sender, e) =&gt; {
              if (ButtonClicked != null) 
                  ButtonClicked (sender, e);
  
          };
          return cell;
  
      } 
  
  
      private class CustomButtonCell: UITableViewCell
      {
          public UIButton btn;
  
  
          public CustomButtonCell(NSString cellId )
              : base(UITableViewCellStyle.Default, cellId)
          {
              SelectionStyle = UITableViewCellSelectionStyle.None;
              Accessory = UITableViewCellAccessory.DisclosureIndicator;
              ContentView.BackgroundColor = UIColor.White;
              btn = ImagewareMobile.iOS.UI.Common.Buttons.ElementsButton("", FitpulseTheme.SharedTheme.BlueButtonImage);
  
  
          ContentView.AddSubviews(new UIView[] {btn});
  
          }
  
          public void UpdateCell (string caption )
          {
              btn.SetTitle(caption,UIControlState.Normal);
  
          }
  
          public override void LayoutSubviews ()
          {
              base.LayoutSubviews ();
              btn.SetTitleColor(UIColor.White, UIControlState.Normal);
              btn.Frame = new CGRect (5,5,300,35);
  
          }
      }
  
  }
  </code></pre>
  
  <p>Sometimes I got the alert message twice or more times. It doesnt happen all time but sometimes happens and it is boring..</p>
  
  <p>in javascript there is preventDefault method, but what about for ios? </p>
  
  <p>I am using xamarin.ios with c# but I can handle code of objective C or swift.</p>