我正在使用此方法,但它僅適用於我的UIView子類。如果我點擊UITextView或UIButton或任何其他對象,它不是顯示座標。如何獲取UITextView的點擊座標?爲什麼發生這種情況?如何獲取水龍頭的座標UITextView
- (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event {
UITouch *userTouch = [[event allTouches] anyObject];
CGPoint currentPos = [userTouch locationInView:self.view];
NSLog(@"Coordinates: (%f,%f)", currentPos.x, currentPos.y);
}
你可能會需要繼承你的UITextView,並應用第二個答案在這裏找到:http://stackoverflow.com/questions/631427/is-there-a-way-to-pass-touches-through-on-the-iphone –
它的工作原理,但它不會識別單個快速點擊(點擊)。我需要按下鼠標按鈕0.2-0.3秒,然後它完美地工作。你知道爲什麼嗎?延遲還是別的? –
你使用滾動視圖嗎?有一個屬性delayedContentTouches,你會想要調整。 –