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 7993095
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T13:45:01+00:00 2026-06-04T13:45:01+00:00

I have a custom table view cell view that contains a button. I initialize

  • 0

I have a custom table view cell view that contains a button. I initialize the button to setBackgroundImage to an empty circle in its normal state. I also setImage to a checkmark image for its selected state.

    checkmarkButton = [[UIButton alloc] initWithFrame:CGRectMake(kLeftMargin, kTopMargin, kButtonSize, kButtonSize)];
    [checkmarkButton setBackgroundImage:[UIImage imageNamed:@"empty-circle.png"] forState:UIControlStateNormal];
    [checkmarkButton setImage:[UIImage imageNamed:@"checkmark.png"] forState:UIControlStateSelected];
    [checkmarkButton addTarget:self action:@selector(checkmarkButtonPressed:) forControlEvents:UIControlEventTouchUpInside];
    [self.contentView addSubview:checkmarkButton];

When the button is clicked on, I set the button as selected and told to redraw so that the button looks like a circle with a checkmark in it. Click on it again and selected is set to NO and the cell is told to redraw so that it’s an empty circle.

- (void)checkmarkButtonPressed:(id)sender
{
    [checkmarkButton setSelected:!checkmarkButton.selected];

    [managedObjectContext save:nil];
}

My problem is that this button exists in a custom table view cell view, which seems to control how it’s drawn in a way that I can’t identify. When I long-click (touch down in the cell and staying in the cell without touching up for a while) on a cell whose button is set selected (should display a checkmark in a circle), the checkmark disappears until I touch up. When I touch up, the state of the cell is correct. It’s just wrong while I am long-clicking the cell.

So, how do I control how that button is drawn when I long-click on the cell?

  • 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-06-04T13:45:02+00:00Added an answer on June 4, 2026 at 1:45 pm

    I’m not sure if this is exactly your case because I didn’t see your sources. But please check the Highlighted state of your button. When UIButton is placed on UITableViewCell then table controls your UIButton: on cell touch down (long touch) UIButton as well as UITableViewCell change its state to Highlighted and returns to Default or Selected state on touch up.

    UPDATE:
    I agree it is unexpected behavior. You can create subclass of UIButton and reimplement this call to leave it empty to prevent calling super method:

    - (void)setHighlighted:(BOOL)highlighted;
    

    Example:

    @interface XButton : UIButton
    @end
    
    @implementation XButton
    - (void)setHighlighted:(BOOL)highlighted { }
    @end
    

    This should prevent state changing by table.

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

Sidebar

Related Questions

I have a custom cell that contains a button in a table view. The
I have a custom Table View Cell that displays the details of a Conference
I have a custom tableview cell created programmatically that consists of: a background view
I have a table cell for which I set its contentView to a custom
I have a custom view in a custom table cell. Every time a specific
I have a custom cell and i displayed that custom cell in a table
i have a not custom table view view that i mean that i'm using
I have a table view with three sections. The first section contains custom cells
I am currently trying to load my custom table view cell from its own
I've a custom table view cell that I created using XIB: I've also linked

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.