How to Recognize Touch Up Internal Gesture from UITouch

I am making a net. It subclasses the tableview and exposes several sub-cells (columns) per cell. It all works fine.

Now I need to determine when a separate sub-cell is used. I have excessive touch. In the grid. Is there a way I can take NSSetobjects UITouchand determine if it was a touch inside or some other gesture?

I could write my own code, but it can be difficult to make it perfect.

+3
source share
3 answers

UIControlEventsas UIControlEventTouchUpInsideused with objects UIControl. In UIViewyou will need to conduct your own testing.

, , - . .

- (void) touchesEnded:(NSSet *)touches withEvent:(UIEvent *)event {
    if ([touches count] == 1) {
        UITouch * touch = [touches anyObject];
        if ([touch tapCount] == 1) {
            // This is a simple tap
            CGPoint point = [touch locationInView:self.view];
            GridCell * cell = nil;
            for (GridCell * aCell in cells) {
                if (CGRectContainsPoint(aCell.frame, point)) {
                    cell = aCell;
                    break;
                }
            }
            if (cell) {
                // The tap was inside this cell
            }
        }

    }
}
+1

, , touchesEnded , . , , .

0

, TableView . . , , .

, ;)

0

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


All Articles