CGPoint location = [touch locationInView:[touch view]]; [英] CGPoint location = [touch locationInView:[touch view]];
问题描述
有人可以解释一下从CGPoint开始的这一行代码的实际情况.这来自-(void)ccTouchesBegan
...
Can someone please explain what's exactly going on with this line of code starting at CGPoint. This comes from the -(void)ccTouchesBegan
...
UITouch* touch = [touches anyObject];
CGPoint location = [touch locationInView:[touch view]];
尤其是我不理解[触摸视图]部分.
In particular I'm not understanding the [touch view] part.
谢谢
推荐答案
[UITouch view]
文档
该属性的值是最初发生触摸的视图对象.该对象可能不是触摸当前所在的视图.
The value of the property is the view object in which the touch originally occurred. This object might not be the view the touch is currently in.
换句话说,它是触摸位置的最里面的视图.但是,如果您点击并移动手指,即使触摸已经在另一个视图中,view
也不会改变.
In other words, it's the innermost view at the touched position. However, if you tap and move the finger, the view
doesn't change even if the touch is already in a different view.
这篇关于CGPoint location = [touch locationInView:[touch view]];的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!