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?

7
  • 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, 2013 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, 2013 at 13:31
  • No, bottom bar is just a ImageView that is displaying to you and its height is fixed i,e: 30px May 30, 2013 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, 2013 at 13:41
  • yeah I have set its frame to center and still it is working like that May 30, 2013 at 13:42

6 Answers 6

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.

7
  • I have setted it as bringSubviewToFront May 30, 2013 at 13:24
  • 1
    If delegate not set properly then upper row should also not work May 30, 2013 at 13:25
  • @Hercules Lasst option is the probable reason
    – Lithu T.V
    May 30, 2013 at 13:26
  • its superView is self.view and if its height were less then back and logout button you are looking should not work as it is below the tableView May 30, 2013 at 13:28
  • 1
    some view was overlapping over last row and was transparent.It was not any otherView.it was its own footerView.That I had return with empty UIView.I set footerheight to 0 and problem solved. Thanks! Jun 11, 2013 at 5:08
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)
2
  • either tried by reducing height of menuTable and increasing height of self.view.frame. Didn't work.Only the last row is half working. May 31, 2013 at 4: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. Oct 18, 2013 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.

2
  • [self.view bringSubviewToFront:table]; May 30, 2013 at 13:31
  • Decrease some height of table. The bottom bar is above table. and bringsubviewtoFront method should have worked for you. May 30, 2013 at 13:33
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.

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.

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.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.