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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T06:51:16+00:00 2026-06-01T06:51:16+00:00

I’m writing an iOS 5 app (in Xcode 4.3, using Storyboards and ARC) that

  • 0

I’m writing an iOS 5 app (in Xcode 4.3, using Storyboards and ARC) that has some table cells that need to respond to horizontal pans. I had a table setup that worked really well but then I needed to implement the same behavior on another scene. I figured the best-practices way would be to abstract out the gesture-recognizing and -handling code into subclasses. But now the tableView won’t scroll, and the solution I had for this problem under the old method doesn’t help.

I have a RestaurantViewController which inherits from UIViewController and has a property ULPanningTableView *tableView. Some of the table’s cells are MenuItemCells and inherit from ULPanningTableViewCell. The table’s delegate and data source are the RestaurantViewController.

ULPanningTableViewCell inherits from UITableViewCell and is pretty close to the original, the only difference being that it has properties to keep track of the cell’s front and back views, and the custom backgrounds.

ULPanningTableView is a bit more complicated, since it has to set up the recognition and handling.

ULPanningTableView.h:

#import <UIKit/UIKit.h>

@interface ULPanningTableView : UITableView <UIGestureRecognizerDelegate>

@property (nonatomic) float openCellLastTX;
@property (nonatomic, strong) NSIndexPath *openCellIndexPath;

- (id)dequeueReusablePanningCellWithIdentifier:(NSString *)identifier;
- (void)handlePan:(UIPanGestureRecognizer *)panGestureRecognizer;
// ... some helpers for handlePan:

@end

and ULPanningTableView.m:

#import "ULPanningTableView.h"
#import "ULPanningTableViewCell.h"

@implementation ULPanningTableView

@synthesize openCellIndexPath=_openCellIndexPath, openCellLastTX=_openCellLastTX;

- (id)initWithFrame:(CGRect)frame
{
    self = [super initWithFrame:frame];
    if (self) {
        // Initialization code
    }
    return self;
}

#pragma mark - Table View Helpers

- (id)dequeueReusablePanningCellWithIdentifier:(NSString *)identifier
{
    ULPanningTableViewCell *cell = (ULPanningTableViewCell *)[self dequeueReusableCellWithIdentifier:identifier];

    UIPanGestureRecognizer *panGestureRecognizer = [[UIPanGestureRecognizer alloc] initWithTarget:self action:@selector(handlePan:)];
    [panGestureRecognizer setDelegate:self];
    [cell addGestureRecognizer:panGestureRecognizer];

    return cell;
}

#pragma mark - UIGestureRecognizerDelegate protocol

- (BOOL)gestureRecognizerShouldBegin:(UIGestureRecognizer *)gestureRecognizer
{
    // for testing: only allow UIScrollViewPanGestureRecognizers to begin
    NSString *gr = NSStringFromClass([gestureRecognizer class]);
    if ([gr isEqualToString:@"UIScrollViewPanGestureRecognizer"]) {
        return YES;
    } else {
        return NO;
    }
}

#pragma mark - panhandling

- (void)handlePan:(UIPanGestureRecognizer *)panGestureRecognizer
{
    // ...
}
// ... some helpers for handlePan:

@end

I’ve played around with gestureRecognizerShouldBegin:, because that was how I solved this problem back when these weren’t separate classes (ULPanningTableView stuff was implemented inside RestaurantViewController and ULPanningTableViewCell was stuff was implemented in MenuItemCell. I would essentially return NO for gestures where the translationInView was more vertical than horizontal). Anyway, I can’t get the table to scroll! I can get the pan gestures to be recognized if I return YES from gestureRecognizerShouldBegin:, or if I remove the UIGestureRecognizerDelegate implementation entirely.

I’m still a beginner in iOS, and in Objective-C, so I only have hunches based on things I’ve read, and I’m under the impression from a similar problem that the culprit is UIScrollViewPanGestureRecognizer doing voodoo with the responder chain…

I would greatly appreciate any light you can shed on this!

  • 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-01T06:51:18+00:00Added an answer on June 1, 2026 at 6:51 am

    Ok, so I feel really silly. -handlePan: is already a method! I changed it to -handleCustomPan: and it will handle other pans normally. I’m not sure why it wasn’t crashing, but there it is. Oh, and I had to keep the UIScrollViewPanGestureRecognizer edge case in -gestureRecognizerDidBegin::

    - (BOOL)gestureRecognizerShouldBegin:(UIGestureRecognizer *)gestureRecognizer
    {
        NSString *gr = NSStringFromClass([gestureRecognizer class]);
        if ([gr isEqualToString:@"UIScrollViewPanGestureRecognizer"]) {
            // allow scroll to begin
            return YES;
        } else if ([gr isEqualToString:@"UIPanGestureRecognizer"]){
            UIPanGestureRecognizer *panGR = (UIPanGestureRecognizer *)gestureRecognizer;
            // allow horizontal pans to begin
            ULPanningTableViewCell *cell = (ULPanningTableViewCell *)[panGR view];
            CGPoint translation = [panGR translationInView:[cell superview]];
            BOOL should = (fabs(translation.x) / fabs(translation.y) > 1) ? YES : NO;
    
            if (!should) {
                [self closeOpenCellAnimated:YES];
            }
    
            return should;
    
        } else {
            NSLog(@"%@",gestureRecognizer);
            return NO;
        }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

That's pretty much it. I'm using Nokogiri to scrape a web page what has
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
I've got a string that has curly quotes in it. I'd like to replace
In my XML file chapters tag has more chapter tag.i need to display chapters
We're building an app, our first using Rails 3, and we're having to build
I need a function that will clean a strings' special characters. I do NOT
I am writing an app with both english and french support. The app requests
I have thousands of HTML files to process using Groovy/Java and I need to
I am using Paperclip to handle profile photo uploads in my app. They upload
link Im having trouble converting the html entites into html characters, (&# 8217;) i

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.