5

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?

Prince Kumar Sharma
  • 12,591
  • 4
  • 59
  • 90
  • I'd suggest pausing the app, and typing `po [[UIWindow keyWindow] recursiveDescription]` at the `(lldb)` prompt of your debugger to get a detailed description of all of the views. You probably have a frame set incorrectly or you have something not visible which is intercepting the taps. To make that `recursiveDescription` useful, liberal use of subclasses and `tag` property can be useful (this suggestion will make sense once your pour through `recursiveDescription` logs a few times). – Rob May 30 '13 at 13:28
  • Does the bottom blue bar image have excess transparency? That transparent portion could be blocking the taps, if you have assigned bottom bar `height=blueimage.size.height` – Amar May 30 '13 at 13:31
  • No, bottom bar is just a ImageView that is displaying to you and its height is fixed i,e: 30px – Prince Kumar Sharma May 30 '13 at 13:33
  • As a quick check, can you set the table view in center of the screen instead of bottom and check if the row is clickable in the said portion? This will clarify if there is no view blocking the click. – Amar May 30 '13 at 13:41
  • yeah I have set its frame to center and still it is working like that – Prince Kumar Sharma May 30 '13 at 13:42
  • The y position of tableview is not in center of the screen – Amar May 30 '13 at 13:43
  • tableview.center=self.view.center done like that – Prince Kumar Sharma May 30 '13 at 13:44

6 Answers6

5

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.

Juan Boero
  • 6,281
  • 1
  • 44
  • 62
Lithu T.V
  • 19,955
  • 12
  • 56
  • 101
5

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)
Aaron Brager
  • 65,323
  • 19
  • 161
  • 287
  • either tried by reducing height of menuTable and increasing height of self.view.frame. Didn't work.Only the last row is half working. – Prince Kumar Sharma May 31 '13 at 04:39
  • This worked for me. I had similar issue. Solved it but adding self.clipsToBounds = YES; to the view, on which my tableView is located. So I determined, that my tableView was beyond the frame of its parent view. – Denis Kutlubaev Oct 18 '13 at 22:07
1

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.

Nishant Tyagi
  • 9,893
  • 3
  • 40
  • 61
1

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

bisma
  • 795
  • 6
  • 26
0

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

Vipin Vijay
  • 393
  • 5
  • 21
0

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.

bisma
  • 795
  • 6
  • 26
Surendra
  • 201
  • 3
  • 6