UIControlEvents
подобно UIControlEventTouchUpInside
используются с UIControl
объектами. В UIView
вам нужно будет провести собственное тестирование.
Теперь я не знаю, как вы структурировали свой вид сетки или какие именно касания вы хотите обнаруживать, но обычно вам нужно что-то подобное. Это ищет один кран и то, что ячейка была нажата.
- (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
}
}
}
}