I'm facing a very strange problem. I'm using a tableView for menu purpose. It is working fine. But the problem is that in last row of that table ,only top half area fires did select event. When I click on mid of the last row did select does not work. And clicking on top half of the cell didSelect is working fine. Can anyone elaborate it?

Here is screenshot I'm using tableView as:-

enter image description here

here is the code I am setting table's y position on didSelect of backTableView.

        UITableView *menuTable=(UITableView*)[self.view viewWithTag:5];
    CGRect rect=[menuTable frame];
    rect.origin.y-=rect.size.height;

    [UIView animateWithDuration:0.3 animations:^{
        [menuTable setFrame:rect];
    } completion:^(BOOL finished) {

        [tableView deselectRowAtIndexPath:[tableView indexPathForSelectedRow] animated:YES];
        isMenuOpen=YES;
        [bgView setFrame:self.view.frame];
        [self.view insertSubview:bgView belowSubview:menuTable];
        for (UIView *view in self.view.subviews) {
            if (view!=menuTable && view.tag!=44) {
                [view setUserInteractionEnabled:NO];
            }
        }
        NSLog(@"animation completed");
    }];

Setted rowHeight to 40
bringSubViewtoFront
TableHeight to 80 

What can I do now?

有帮助吗?

解决方案 2

Any one will be causing the problem

  • some view above that is overlapping the tableview
  • Height of tablecell not properly set
  • Delegate not set properly
  • Make sure the tableview frame and its superview frame is set properly[if the superview is having lesser height this problem occours]
  • If having footer or header and more than one section, check delegate methods to filter wich table view should show header/footer and also check height.

You could also use the visual debugging tools added to Xcode to see views order in a 3d fashion, and check which one is over the other.

其他提示

The superview of your table view (in this case, self.view) has a frame that ends higher than the bottom of your table view.

You can see this if you set:

self.view.clipsToBounds = YES;

To fix this, you'll need to either

  • Make menuTable's frame shorter (decrease height of menuTable.frame)
  • Make self.view's frame taller (increase height of self.view.frame)

This is because there is some control above your table view . So either Use bringSubviewToFront: method to bring it in top

     [self.view bringSubviewToFront:table];

or

Change table frame(Decrease some height of your table).

Hope it helps you.

I had the same issue and was only resolved by setting tableview's footer height to 1. May be it help someone in future.

Most probably this will be the problem with setting the frame. Please check whether you set the frame correctly. It should fit with superview.

I solved it by adding footer view and setting footer height like below.

 (UIView *)tableView:(UITableView *)tableView viewForFooterInSection:(NSInteger)section
    {    
    UIView *footer=[[UIView alloc]initWithFrame:CGRectZero];
    return footer;    
    }

 (CGFloat)tableView:(UITableView *)tableView heightForFooterInSection:(NSInteger)section
    {
        return 1;    
    }

Even though the problem is not solved, add an extra cell in the last and disable user interaction to that cell.

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top