Hide UITableView on touches outside the tableview

前端 未结 3 1406
心在旅途
心在旅途 2021-01-25 00:13

I have a small UITableView that is hidden when the view is loaded. When i click on \"SHOW\" UIButton, the UITableView<

3条回答
  •  心在旅途
    2021-01-25 00:43

    Subclass UITableView, override pointInside:withEvent:. It is templated for this reason.

    Something like:

    -(BOOL)pointInside:(CGPoint) point withEvent:(UIEvent*) event
    {
        BOOL pointIsInsideTableView = [super pointInside:point withEvent:event];
        BOOL pointIsOutsideTableView = // Some test
        return pointIsInsideTableView || pointIsOutsideTableView;
    }
    

    So you can catch the touch in table view implementation, where it belongs logically in this case.

提交回复
热议问题