2012-10-31 2 views
0

나는 사람이 지구의 이미지를 드래그 할 수 있도록 앱을 작성하려고합니다.사용자가 이미지를 드래그 할 수 있도록 간단한 앱을 작성하려고 시도합니다.

사용자가 자신의 발을 드래그하기 시작 때 호출하지만, 드래그 결코 극복 있도록 [[ event allTouches] anyObject] 결코의 earth 객체를 반환됩니다 touchesmoved에있어서,

-(void)touchesMoved:(NSSet *)touches withEvent:(UIEvent *)event { 

    UITouch *touch=[[ event allTouches] anyObject]; 

    if ([touch view] == earth) 
    { 
     CGPoint location = [ touch locationInView: self.view]; 
     earth.center=location;   
    } 
} 
+0

왜 'touches'대신 [[event allTouches] '를 사용하고 있습니까? – slf

답변

0

터치 사용을 UITouch *touch=[touches anyObject];

변경을 얻기 위해 touchesMoved: 님의 답변 :

- (void)touchesMoved:(NSSet *)touches withEvent:(UIEvent *)event 
{ 

    UITouch *touch=[ touches anyObject]; 

    if ([touch view] == earth) 
    { 
     CGPoint location = [ touch locationInView: self.view]; 
     earth.center=location;   
    } 
} 
+0

안녕하세요, Stil이 작동하지 않았습니다. 지구의 기록을 남기고, 그 다음에 위치가 내부인지 확인하기 위해 –

관련 문제