0

I don't know if this is the best way but, in our application, we have a CustomCell class to show datas in a table view.

Until the last week, it was working properly.

Currently the button TouchUpInside event is not triggered.

Maybe the new iOS version ?

Any idea, please?

Here is the class :

public class CustomCell : UITableViewCell
{
    public static readonly string ID = "CustomCell";
    public UILabel FullName;
    public UILabel BirthDate;
    public UILabel Phone;
    public UILabel Observations;
    public UILabel Gender;
    public int PatientID;
    public UIButton Modify;
            
    public CustomCell ()
    {
        Gender = new UILabel (new CGRect (15, 0, 85, 35)) {
            Font = UIFont.FromName ("Trebuchet MS", 14f)
        };
        

        FullName = new UILabel (new CGRect (100, 0, 200, 35)) {
            Font = UIFont.FromName ("Trebuchet MS", 14f)
        };

        BirthDate = new UILabel (new CGRect (310, 0, 100, 35)) {
            Font = UIFont.FromName ("Trebuchet MS", 14f)
        };
        Phone = new UILabel (new CGRect (435, 0, 110, 35)) {
            Font = UIFont.FromName ("Trebuchet MS", 14f)
        };

        Observations = new UILabel (new CGRect (550, 0, 450, 35)) {
            Font = UIFont.FromName ("Trebuchet MS", 13f)
        };

        Modify = new UIButton (new CGRect (270, 5, 28, 28)){ };

        var img = UIImage.FromFile("edit.png");
    
        Modify.SetBackgroundImage (img, UIControlState.Normal);
        Modify.AutoresizingMask = UIViewAutoresizing.FlexibleLeftMargin;
        Modify.TouchUpInside += ModifyTouchUpInside;

        AddSubview (Gender);
        AddSubview (FullName);
        AddSubview (BirthDate);
        AddSubview (Phone);
        AddSubview (Observations);

        if(Tools.ShowModifyIcon)
          AddSubview (Modify);
        this.ContentView.UserInteractionEnabled = true;
    }


    
    void ModifyTouchUpInside (object sender, EventArgs e)
    {
        try {

            Tools.PatientsPage.ShowPopup (this.PatientID);

        } catch (Exception ex) {
            UserMethods.ParseError (ex, "Err139");
        }
    }

}
Coskun Ozogul
  • 2,389
  • 1
  • 20
  • 32
  • It's not related with the new iOS version. The simple and easiest way is to detect button event and perform some action or you can set tag of the button and perform action based on the tag. For more details, you can refer to https://stackoverflow.com/a/28895402/9644964. Last but not least, it's better to create a [Minimal, Reproducible Example](https://stackoverflow.com/help/minimal-reproducible-example) via github repo link, I can help you take a look. Thanks in advance! – Alexandar May - MSFT Apr 13 '23 at 03:18
  • In fact, I found the solution. In the CustomCell class, in the constructor, I added this.ContentView.UserInteractionEnabled = false. And it works. I don't know if I should remove the question or not. – Coskun Ozogul Apr 13 '23 at 07:50
  • I think it is related to iOS version because it was working until now. After the last updates it started not to work. – Coskun Ozogul Apr 13 '23 at 07:52
  • Terrific! Have a good day! – Alexandar May - MSFT Apr 13 '23 at 08:59

1 Answers1

1

Coskun managed to fix this problem by simply doing below in the CustomCell:

this.ContentView.UserInteractionEnabled = false;
Alexandar May - MSFT
  • 6,536
  • 1
  • 8
  • 15