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

Custom table header - Events subscription/un-subscription

$
0
0

Hello there,

If you create a custom header for a UITableView, and you want to listen for some events on that header (ie: button TouchUpInside); what is the best place for subscribe and un-subscribe for that event?

Some sample code:

public override UIView GetViewForHeader (UITableView tableView, int section)
{
    var view = new UIView (new RectangleF (0, 0, tableView.Bounds.Width, 44));

    var label = new UILabel (new RectangleF (10, 17, 120, 16)) { 
        Text = "Test",
        TextAlignment = UITextAlignment.Left,
        Font = UIFont.FromName ("Helvetica-Bold", 15)
    };

    AddButton.Center = new PointF (tableView.Bounds.Width - 20, 24);
    AddButton.TouchUpInside += HandleActivityAddTouched;

    view.AddSubviews (label, AddButton);

    return view;
}

As you can see above, I'm registering for TouchUpInside on the AddButton however I can't find a suitable place for un-register this event.

Thanks, R.


Viewing all articles
Browse latest Browse all 204402

Trending Articles



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