views:

243

answers:

1

I'm programming an app in which one of the ViewControllers is showing an UIScrollView that shows an image.

I'd like to load an image (pushpin in png format) and draw it (and delete it) in some points of the UIScrollView image.

I'd also would like to draw bezier paths in that image (and deleting them).

I've programmed several apps but this is the first time I face graphic programming and don't know where to start from.

Any suggestions?

Thanks!

A: 

Hi

You could set the tag for the view you add to the scrollView.

This means you can get a reference to the view later on by:

    UIView * myView = (UIView*)[myScrollView viewWithTag:CONTENT_TAG];
    //Then add a pin
    [myView addSubView:myPinView];

If you want to remove the pin again, you can use the same approach, set the tag on the pinView and get a reference to it later on and call removeFromSuperView on it.

You can also chose to build properties for both scroll content and pin, but the above (assuming you only need to reference it in conjunction with the scrollView) makes for a lot less code and, in my view, a easier to read implementation (giving the tags descriptive names like:

#define SCROLL_CONTENT_VIEW 9000
#define CONTENT_VIEW_PIN 9001

So it is:

UIView * myView = (UIView*)[myScrollView viewWithTag:SCROLL_CONTENT_VIEW];
//and
UIView * myPin = (UIView*)[myView viewWithTag:CONTENT_VIEW_PIN];

Hope this was what you were after:)

RickiG
Thanks for the answer RickiG. That solves the 1st part of my question.
Jorge