views:

24

answers:

2

I was wondering if anyone would be able to tell me how you would go about this?

e.g. - User pushes (+) Add Button - Image appears to let user set start point of line - After user sets the first point a second image appears and a line is drawn between them and animated between them as user moves the second image into place.

You could see this sort of action in just about any graphics drawing program where a user is required to draw a line; except to help the user know where he is drawing I am including a start/end point image to drag about.

I can draw a line no problems. I am perplexed a little by this as the two images I generate for the user to drag around and set as start/end point are both instances of a class I created (draw2d) that subclasses UIImageView (so I can drag it about).

So at present I am adding two UIImageViews to my UIViewController in order to drag them about - you can't draw a line between two UIImageViews as such as the only drawing I know how to do is IN the UIImageView.

Do I need to nest these two images in a parent-style UIImageView so I can draw between them?

Any assistance is always greatly appreciated.

A: 

If I understand correctly, you want to draw the line while the user drags their finger around to set the endpoint?

Can't you just track the dragging positions and re-draw the line each time it changes, using the last dragged position as the 'temporary end point'?

Jorge Israel Peña
I'll try that and let you know. I guess I should be able to tap into these values as you say and just keep redrawing the line each time touchesMoved fires. Will keep you posted - anyone with any sample code would save my life!
Lance
A: 

Do I need to nest these two images in a parent-style UIImageView so I can draw between them?

Yes.

No one in particular