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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T10:36:04+00:00 2026-05-26T10:36:04+00:00

I have an UIView high 30, than i add an UITableView as subview with

  • 0

I have an UIView high 30, than i add an UITableView as subview with 30 as origin.y. Because the table remains “under” the main view I cannot select the cells. Consequently I have implemented this method:

 - (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event {
    NSLog(@"Tocco intercettato");
    if (oldSet && oldEvent) {
        [table touchesEnded:oldSet withEvent:oldEvent];
    }
    oldSet = touches;
    oldEvent = event;
    [table touchesBegan:touches withEvent:event];
    [table touchesEnded:touches withEvent:event];
    }

The taps work, but the slides does not work and consequently I cannot slide the table. Some idea in order to resolve?

  • 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-26T10:36:04+00:00Added an answer on May 26, 2026 at 10:36 am

    Passing the touches from an overlying UIView to an underlying UITableView does not work (as you’re seeing, the taps go through but not the scrolling movements). This is because UITableView (as a subclass of UIScrollView) does all sorts of under-the-hood weirdness with the responder chain (your code is also kind of odd, where you call both touchesBegan and touchesEnded from the overlying view’s touchesBegan method, but this isn’t why you can’t scroll the table).

    A simple way to achieve what you want (assuming I’ve understood that correctly) is to override the hitTest:withEvent: method on your overlying view and have the method return the underlying UITableView (instead of self, which is the default implementation):

    - (UIView *)hitTest:(CGPoint)point withEvent:(UIEvent *)event {
        UITableView *tv = (UITableView *)[self.superview.subviews objectAtIndex:0];
        return tv;
    }
    

    Note that this code assumes the UITableView is the first view added to your view controller, and that the overlying UIView is added after that.

    Edit: OK, after re-reading your question, I think I understand your question. You have a main view with a height of 30, and to that view you’ve added a UITableView at y = 30. I think adding this method to your main view will do what you need:

    - (UIView *)hitTest:(CGPoint)point withEvent:(UIEvent *)event {
        if (point.y < self.frame.size.height) {
            return self;
        } else {
            return myTableView; // assumes myTableView is a reference to the
                                // UITableView that you've added
        }
    }
    

    Essentially, you’re telling the OS to pass all touches on to myTableView if they’re outside the bounds of your main view.

    However, a simpler way would be to add both the 30-pixel-high main view (the orange thing) and the UITableView as subviews of another view (or view controller). That way, you wouldn’t have to do anything kludgy to get your table to behave like a normal table.

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

Sidebar

Related Questions

I have a UIViewController. Its view contains a UITableView as a subview. On viewDidAppear,
I have UIView designed in IB, and UITableView on it. In view contoller's viewDidLoad
I have a UIView in a table view section header that I would like
I have a UIView with a UITableView for a subview. The UIView has an
I have a UIView element which I am adding to the main view controller.
I have a UIView in which I added a UITapGestureRecognizer . Inside that view
I have a UIViewController subclass to control a UIView that I want to add
I have a UIView with an alpha of 0.5 which I add as a
I have a UIView that I am setting as the property of a UITableView
I have an UIView and I add a editable UITextView to it, UITextView *textView

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.