UITableView last row didSelect not working properly?

I have a very strange problem. I use tableView to assign a menu. It is working fine. But the problem is that in the last row of this table, only events with the upper half of the area made an event selection. When I click on the middle of the last line, the selection does not work. And clicking on the upper half of the didSelect cell works fine. Can anyone develop it?

Here is a screenshot. I use tableView as: -

enter image description here

here is the code i set for table y position on didSelect 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?

+4
source share
6 answers

Any of them will cause a problem.

  • some view above that overlays the table view
  • Table height not set correctly
  • The delegate is not installed correctly
  • Make sure the tableview frame and its supervisor frame are set correctly [if the add-in is of lower height, this problem occurs)
  • If you have a footer or header and several sections, check the delegation methods so that the filter displays the header / footer and also checks the height.

You can also use the visual debugging tools added in Xcode to see the order of views in 3d mode and check which one is above the other.

+4
source

The view in your table view (in this case self.view ) has a frame that ends above the bottom of the table view.

You can see this if you install:

self.view.clipsToBounds = YES;

To fix this, you will need

  • Decrease menuTable (decrease height from menuTable.frame )
  • Make the self.view frame higher ( height increase from self.view.frame )
+5
source

I had the same problem and solved this problem by setting the footer height to 1. Maybe this will help someone in the future.

+1
source

Most likely, this will be a problem with setting the frame. Check that the frame is installed correctly. It must match the supervision.

0
source

This is because there is some control over the table view. So either use the bringSubviewToFront: method to bring it to the top

  [self.view bringSubviewToFront:table]; 

or

Change table frame (Reduce some table height).

Hope this helps you.

0
source

I solved it by adding a footer and setting the height of the footer as shown 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 if the problem is not resolved, add an additional cell to the last one and disable user interaction with this cell.

0
source

Source: https://habr.com/ru/post/1483586/


All Articles