有人能解释一下CGPoint开始的这段代码到底是怎么回事。这来自-(void)ccTouchesBegan
...CGPoint位置= [touch locationInView:[touch view]];
UITouch* touch = [touches anyObject];
CGPoint location = [touch locationInView:[touch view]];
特别是我不理解[触摸视图]的一部分。
由于
有人能解释一下CGPoint开始的这段代码到底是怎么回事。这来自-(void)ccTouchesBegan
...CGPoint位置= [touch locationInView:[touch view]];
UITouch* touch = [touches anyObject];
CGPoint location = [touch locationInView:[touch view]];
特别是我不理解[触摸视图]的一部分。
由于
特别我不理解[触摸视图]部分。
[touch view]
是用户实际接触到的UIView。
你可能会通过读取触摸我的书的章节(至少前几页)进一步帮助:
[UITouch view]
文档
属性的值是视图最初发生触摸的对象。此对象可能不是触摸当前所在的视图。
换句话说,它是触摸位置处的最内部视图。但是,如果点击并移动手指,即使触摸已处于不同视图,view
也不会更改。
所以在[touch view]中,view是一个属性,而不是方法? – user2252901 2013-04-06 19:12:07
@ user2252901在Objective-C中,属性是1或2个方法(getter或getter&setter)的名称,因此您的问题没有意义。 'view'是'readonly'属性,换句话说,它是一个getter方法。 – Sulthan 2013-04-06 19:40:51