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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T04:55:53+00:00 2026-06-15T04:55:53+00:00

I have a LongPress gesture recognizer initialized in the viewDidLoad method of my viewcontroller

  • 0

I have a LongPress gesture recognizer initialized in the viewDidLoad method of my viewcontroller as below:

longPressGesture_= [[UILongPressGestureRecognizer alloc] initWithTarget:self action:@selector(displayTimeFlagCallout)];

I have a tableview in my viewcontroller. The tableview has custom cells. Each cell has 2 textfields. I want to bring up a custom popover when a user long presses on the text fields (startTime and endTime). I do not want the magnifying glass and the Copy/Paste popover to show up on long press of textfield as the standard behavior and hence before adding my gesture recognizer, I am disabling the in-built long press gesture recognizer of the text fields. I have added the following code to my cellforRowAtIndexPath method:

MyCustomCell_iPhone *cell = [tableView dequeueReusableCellWithIdentifier:cellID];

if (cell == nil)
  {
    cell = [[MyCustomCell_iPhone alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:cellID];


      for (UIGestureRecognizer *recognizer in cell.startTime.gestureRecognizers) {
          if ([recognizer isKindOfClass:[UILongPressGestureRecognizer class]]){
              recognizer.enabled = NO;
          }
      }
      for (UIGestureRecognizer *recognizer in cell.endTime.gestureRecognizers) {
          if ([recognizer isKindOfClass:[UILongPressGestureRecognizer class]]){
              recognizer.enabled = NO;
          }
      }

      [cell.startTime addGestureRecognizer:longPressGesture_];
      [cell.endTime addGestureRecognizer:longPressGesture_];


  }

However, this is not working. Nothing happens on long press now. Any ideas what could be the issue?

Thanks
Hetal

  • 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-15T04:55:54+00:00Added an answer on June 15, 2026 at 4:55 am

    Three thoughts:

    1. You cannot use the same long press gesture recognizers for two controls. You have to create a separate gesture recognizer for each control.

    2. It would appear that the gesture recognizers get reset when you start editing in text field (assuming you allow editing in the text field). I assume you allow editing of the text field, and, if so, I believe that you have to set a delegate that will disable the long gesture recognizer that is not your own. (You can do that, for your long press gesture recognizer, subclass it as, say CustomLongPressGestureRecognizer, use that for your text field’s gesture recognizers and then you can disable any UILongPressGestureRecognizer objects that are not your own CustomLongPressGestureRecognizer.)

    3. I infer from your code that you’re not using storyboards and prototype cells, because in that scenario, cell is never nil and your if statement would never end up invoking your code. But if you’re using NIBs or not using prototype cells, then you should be fine on this point.

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

Sidebar

Related Questions

In my longpress gesture i have an problem like, *mypressrec = [[UILongPressGestureRecognizer alloc] initWithTarget:self
CODE I have some code that adds a UILongPressGestureRecognizer gesture recognizer called _recognizer to
In cellForRowAtIndexPath: method I have implemented gesture recognizer for long press, -(UITableViewCell *)tableView:(UITableView *)tableView
Here's my setup. I have a viewcontroller that I'm creating and adding as a
I have 2 buttons with UILongPressGestureRecognizer, to do it, i do: Fot button 1:
I was interested in using a UIGestureRecognizer subclass (UILongPressGestureRecognizer) in a ViewController Subclass I
guys, I have added two UILongPressGestureRecognizer. What I want is when two buttons are
I have UIView with animated frame size on long press gesture. - (IBAction)longPressGesture:(id)sender {
I have a UILongPressGestureRecognizer added to a UIButton. When I press the UIButton it
I have made it so that the UILongPressGestureRecognizer drops a pin, but I want

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.