Touch events on UITableView?

2019-01-30 15:06发布

I have UIViewControllerand UITableView as child in the view, what I want to do is when I touch any row I am displaying a view at bottom. I want to hide that view if the user touch any where else then rows or the bottomView.

The problem is when I click on UITableView it doesn't fires touchesEnded event.

Now how can I detect touch on UITableView and distinguish it with row selection event.

Thanks.

7条回答
狗以群分
2楼-- · 2019-01-30 15:57

To receive touch events on the UITableView use:

- (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event
{
  //<my stuff>

  [super touchesBegan:touches withEvent:event];
}

- (void)touchesMoved:(NSSet *)touches withEvent:(UIEvent *)event
{
   //<my stuff>

   [super touchesMoved:touches withEvent:event];
}

- (void)touchesEnded:(NSSet*)touches withEvent:(UIEvent*)event
{
  //<my stuff>

  [super touchesEnded:touches withEvent:event];
}

- (void)touchesCancelled:(NSSet*)touches withEvent:(UIEvent*)event
{
   //<my stuff>
   [super touchesCancelled:touches withEvent:event];
}

receive touch events in UITableView

查看更多
登录 后发表回答