objective c - something strange about TouchesMoved -
i want output coordinate of each touch. , here code:
- (void)drawrect:(cgrect)rect { [[uicolor blackcolor] set]; (int = 0; i<_touches.count; i++){ cgpoint pos=[[_touches objectatindex:i] locationinview:self]; nsstring* str = [nsstring stringwithformat:@" %d:(%d,%d)",i+1,(int)pos.x, (int)pos.y]; [str drawatpoint:cgpointmake(0,16+16*i) withfont:font]; } } - (void)touchesbegan:(nsset *)touches withevent:(uievent *)event{ nsarray* objects = [touches allobjects]; (int i=0;i<objects.count;i++){ [_touches addobject:[objects objectatindex:i]]; } [self setneedsdisplay]; } - (void)touchesmoved:(nsset *)touches withevent:(uievent *)event{ [self setneedsdisplay]; }
it works. output like: 1:(20, 50) 2:(30, 69) ... thing is, every time dragging on screen, coordinate of latest touch changing while dragging. believe touchesmoved doesn't have effects _touches coordinate of each touch stored, latest coordinate should not changing while moving (dragging). helps appreciated. lot.
Comments
Post a Comment