0

我正在使用 iOS 5.x SDK,我想确定屏幕是否已被点击

现在只是建立一个 NSLog 很好,但我不知道从哪里开始

4

2 回答 2

3

通常带有手势识别器,例如,

UITapGestureRecognizer *tap = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(tapOnView:)];
[self.view addGestureRecognizer:tap];

然后你有一个方法,如:

- (void)tapOnView:(UITapGestureRecognizer *)sender
{
    CGPoint location = [sender locationInView:self.view];
    NSLog(@"Tap at %1.0f, %1.0f", location.x, location.y);
}
于 2012-07-20T19:08:01.890 回答
1

您可能希望从实现touchesBegan:withEvent:, touchesMoved:withEvent:, touchesEnded:withEvent:,开始touchesCancelled:withEvent:

您可以在此处阅读有关它的更多信息:UIResponder 类参考

于 2012-07-20T19:08:33.810 回答