Quantcast
Channel: Recent Threads — Xamarin Community Forums
Viewing all articles
Browse latest Browse all 204402

UIButton Click within a UITableViewCell

$
0
0

Hi,

I am seeing a strange behaviour when using a UIButton within a UItableViewCell. When the button is clicked, the event is being called multiple times. Here is the code that I am using, when I ran this in debug with a breakpoint at cell.Tag = indexPath.Row, it hit the breakpoint multiple times on the button click. Any ideas why this is happening?

namespace Test.UI.iOS { public class VZRESMainTableViewDataSource : UITableViewDataSource { public VZRESMainTableViewDataSource () { }

    public override int RowsInSection (UITableView tableView, int section)
    {
        if (VZWorkManagementViewModel.Instance.ResourceList != null) {
            return VZWorkManagementViewModel.Instance.ResourceList.Count;
        }
        return 0;
    }

    public override int NumberOfSections (UITableView tableView)
    {
        return 1;
    }


    public override UITableViewCell GetCell (UITableView tableView, MonoTouch.Foundation.NSIndexPath indexPath)
    {
        VZRESMainTableViewCell cell;
        NSString reuseIdentifier = new NSString ("ResourceCell");


        try
        {
            cell = (VZRESMainTableViewCell)tableView.DequeueReusableCell(reuseIdentifier, indexPath);

            cell.btnTimeEntry.TouchUpInside += (object sender, EventArgs e) => {
            /*test code*/ cell.Tag = indexPath.Row;

                };

            return cell;
        }
        catch {
            cell = new VZRESMainTableViewCell (IntPtr.Zero);

            return cell;
        }
    }
}

}

Thanks Ajay


Viewing all articles
Browse latest Browse all 204402

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>