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

  • Home
  • SEARCH
  • 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 935397
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T21:09:02+00:00 2026-05-15T21:09:02+00:00

CODE I have some code that adds a UILongPressGestureRecognizer gesture recognizer called _recognizer to

  • 0

CODE

I have some code that adds a UILongPressGestureRecognizer gesture recognizer called _recognizer to a subclass of a UITableViewCell called cell:

...
UILongPressGestureRecognizer *_recognizer = [[UILongPressGestureRecognizer alloc] initWithTarget:self action:@selector(cellLongPressRecognized:)];
_recognizer.allowableMovement = 20;
_recognizer.minimumPressDuration = 1.0f;
[[cell contentView] addGestureRecognizer:_recognizer];
[_recognizer release];
...

The -cellLongPressRecognized: selector simply logs when the gesture ends:

- (void) cellLongPressRecognized:(id)_sender {
    if (((UILongPressGestureRecognizer *)_sender).state == UIGestureRecognizerStateEnded)
        ALog(@"[MyViewController] -cellLongPressRecognized: gesture ended...");
}

My console shows one log message when I tap, hold and release a cell:

[MyViewController] -cellLongPressRecognized: gesture ended...

So far, so good.

ISSUE

The issue is that the table cell’s background stays selected only as long as 1.0 second, the _recognizer.minimumPressDuration property.

If I hold my finger on the device any longer than 1.0 second, the cell’s background flips back from the UITableViewCellSelectionStyleBlue selection style to its usual, opaque, non-selected background.

To make sure only gesture-specific code is involved with this issue, I have disabled -tableView:didSelectRowAtIndexPath: while testing.

QUESTION

How do I keep the background selected indefinitely, flipped back only when the “long press” gesture ends?

  • 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-15T21:09:02+00:00Added an answer on May 15, 2026 at 9:09 pm

    I changed my test condition from UIGestureRecognizerStateEnded to UIGestureRecognizerStateBegan and the gesture is timed with the cell selection state change:

    - (void) cellLongPressRecognized:(id)_sender {
        if (((UILongPressGestureRecognizer *)_sender).state == UIGestureRecognizerStateBegan)
            ALog(@"[MyViewController] -cellLongPressRecognized: gesture began...");
    }
    

    Seems counterintuitive naming the event this way, but that seems to work.

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

Sidebar

Ask A Question

Stats

  • Questions 481k
  • Answers 481k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer I like ASIHTTPRequest framework for downloading. You may also use… May 16, 2026 at 6:36 am
  • Editorial Team
    Editorial Team added an answer This isn't possible. The best you can hope for is… May 16, 2026 at 6:36 am
  • Editorial Team
    Editorial Team added an answer You need to use struct MENUITEM *items_ptr;. Note the use… May 16, 2026 at 6:36 am

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

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.