2

I have uiview , that I zoom in and out in it

I associate it with pinchRecognizerMeasure using

pinchRecognizerMeasure = [[UIPinchGestureRecognizer alloc] initWithTarget:self action:@selector(MeasureAndDraw:)];
[pinchRecognizerMeasure setDelegate:self];
[DrawLine addGestureRecognizer:pinchRecognizerMeasure];
[pinchRecognizerMeasure release];

the code of MeasureAndDraw

    // get position of touches, for example:
    NSUInteger num_touches = [pinchRecognizerMeasure numberOfTouches];

    // save locations to some instance variables, like `CGPoint location1, location2;`
    if (num_touches >= 1) {

        DrawLine.startPoint = [pinchRecognizerMeasure locationOfTouch:0 inView:DrawLine];
    }
    if (num_touches >= 2) {

        DrawLine.endPoint = [pinchRecognizerMeasure locationOfTouch:1 inView:DrawLine];
    }

startPoint , endPoint are CGPoint , I want to get the equivalent pixel to it

what shall I do is it correct to do something like

startPoint.X * DrawLine.contentScaleFactor to get the pixl x coordinate or what shall I do

I read http://developer.apple.com/library/ios/#documentation/2DDrawing/Conceptual/DrawingPrintingiOS/GraphicsDrawingOverview/GraphicsDrawingOverview.html , but get confused

any suggestion

AMH
  • 6,363
  • 27
  • 84
  • 135
  • Why do you think you need pixels? Most of the time, it is points what you need. – Eiko Jun 29 '11 at 12:29
  • 1
    Have a look at his [previous question](http://stackoverflow.com/questions/6436990/draw-line-with-gesture) He's looking to be able to get a measurement of line length by translating the pixel length to real length using a scale that he has in pixels. But points are not necessarily pixels in iOS. – Abizern Jun 29 '11 at 12:38

1 Answers1

4

Have a look at the contentScaleFactor property of UIView to translate between points and pixels on the device if you really need to.

Abizern
  • 146,289
  • 39
  • 203
  • 257