Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6619213
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T20:56:16+00:00 2026-05-25T20:56:16+00:00

I’ve made a custom uitableviewcell . The cell consist out of labels and a

  • 0

I’ve made a custom uitableviewcell . The cell consist out of labels and a UIButton. Everything was working fine until I found out that there is a small problem with the reusable cell in combination with adding an event to an uibutton.
So the first time the cell works great when I click the uibutton. But the moment I scroll it starts giving me the wrong detail info. If I comment out the reusable cell part (and let it make a new cell everytime) it just works fine with no problems. So my assumptions is that the event ‘hangs on’ into cell with the old info.
I add the event like this:

myButton.TouchDown += delegate{
  //some code here
}

Obviously I cannot unregister it like this right?
What is the easiest way to overcome this particular problem in monotouch?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-25T20:56:17+00:00Added an answer on May 25, 2026 at 8:56 pm

    OK. I’ve been trying a lot of stuff to solve this but ChrisNTR came with the right solution to my particular problem. I will show his example snippet here:

    public override UITableViewCell GetCell (UITableView tableView, NSIndexPath indexPath)
    {
    var cell = tableView.DequeueReusableCell("reuseThis");
    if(cell == null)
    {
    cell = new UITableViewCell(UITableViewCellStyle.Default, "reuseThis");
    }
    
    cell.TextLabel.Text = Convert.ToChar(dash.oneToHundred[indexPath.Row]).ToString();
    
    var button = UIButton.FromType(UIButtonType.RoundedRect);
    button.Frame = new System.Drawing.RectangleF(40f, 0f, 280f, 40f);
    button.SetTitle(dash.oneToHundred[indexPath.Row].ToString(),UIControlState.Normal);
    button.AddTarget (this, new Selector ("MySelector"), UIControlEvent.TouchDown);
    button.Tag = indexPath.Row;
    cell.ContentView.AddSubview(button);
    
    return cell;
    }
    
    [Export ("MySelector")]
    void ButtonEventHere (UIButton button)
    {
    
    Console.WriteLine ("Hello! - Button clicked = " + button.Tag );
    Console.WriteLine ( Convert.ToChar(dash.oneToHundred[button.Tag]).ToString() );
    }
    

    In short you call button.AddTarget() and you pass the corresponding values to the button. one of these values is the selector which you defined as ‘buttonEventHere’ (can be any name you want it to me my sure that the [export(“MySelector”)] has the right name). Make sure you pass the indexPath.Row to the button.Tag. You will use that index to know which button was pressed and do your action accordingly.

    Hope this helps if you was stuck as i was.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I had made custom example by taking reference from here Example is working fine
I've made a custom DataGridViewCell that displays a custom control instead of the cell;
I made a custom control that is basically a multiline TextBox that allows input,
I made a custom handler that derives from MvcHandler. I have my routes using
I have a UITableview made up with a custom cell loaded from a nib.
I made a custom cell with a XIB: .h #import <UIKit/UIKit.h> @interface TWCustomCell :
I made a custom DatePicker that extends the android DatePicker UI component. I needed
I have a custom UITableViewCell which has some subviews. i.e. some labels, some images.
I made a custom cell for a UITableView (subclassing UITableViewCel, e..., and with a
in my custom made cms, i need to replace part of the text that

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.