![](/img/trans.png)
[英]How do I determine the indexPath for cell with a switch that has been tapped?
[英]iOS how to determine if the screen has been tapped
我正在使用iOS 5.x SDK,我想確定屏幕是否被輕按
就目前而言,建立一個NSLog很好,但是我不知道從哪里開始
通常使用手勢識別器 ,例如
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);
}
您可能想從實現touchesBegan:withEvent:
, touchesMoved:withEvent:
, touchesEnded:withEvent:
, touchesCancelled:withEvent:
。
您可以在這里閱讀有關它的更多信息: UIResponder類參考
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.