2010-06-18 6 views
4

CGPoint를 문자열로 변환 할 때 문제가 발생했습니다. 나는 여러 가지 방법을 시도했지만 이것이 가장 유망한 것 같지만 여전히 효과가 없을 것입니다. 어떤 제안?CGPoint를 문자열로 변환 할 때의 문제

-(void)touchesMoved:(NSSet *)touches withEvent:(UIEvent *)event { 
    UITouch *touch = [[event allTouches] anyObject]; 
    coord = [touch locationInView:touch.view]; 
    viewcoord.text = [NSString stringWithFormat:@"coordinates %@", coord.x, coord.y]; 

I 출력을 얻을 수 있지만, 그것은 단지 말한다 "좌표 (널)를"내가 왜 이해가 안 ...

감사

답변

1

귀하의 형식 : 여기

내 코드입니다 string은 objective-C 오브젝트에만 적용되는 %@을 사용합니다. 두 가지 값 (x와 y)이 아니라 두 개 모두를 플로트로 인쇄하려고합니다. 사용해보기 :

viewcoord.text = [NSString stringWithFormat:@"coordinates %f, %f", coord.x, coord.y]; 
14
viewcoord.text = [NSString stringWithFormat:@"coordinates %@", NSStringFromCGPoint(coord)]; 
관련 문제