Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

UITableView does not respond to scrolling and touches

I've created a custom UIView, and inside that UIView, I add a UITableView like thus:

    treeView = [[UITableView alloc] initWithFrame:CGRectMake(0, 80, slider.frame.size.width, slider.frame.size.height - 80)];
    [treeView setDelegate:self];
    [treeView setDataSource:self];
    [self addSubview:treeView];
    [treeView release];

When the app loads, the table seems to load fine. However, when I try to scroll the table, it does not respond to the touches at all.

I also implement these delegate/data source methods:

- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView;
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section;
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath;
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath;

Does anyone have any idea why this is so?

Thanks

like image 818
AugmentedGuy Avatar asked Nov 29 '22 17:11

AugmentedGuy


1 Answers

There are several possibilities:

  • Your custom view, or one of its superviews, has userInteractionEnabled set to NO.
  • There is another view on top of your custom view, or on top of the table view within the custom view.
  • The custom view that the table view is inside is smaller than the table view (with clipsToBounds=NO, a subview that extends beyond the bounds of its parent can be seen but not normally interacted with). Or the same for another view in the stack.
  • The custom view (or one of its superviews) overrides pointInside:withEvent: or hitTest:withEvent: incorrectly.
like image 89
Anomie Avatar answered Dec 06 '22 02:12

Anomie