Search code examples
iosuiscrollviewtagging

Adding texts to an UIImageView like tagging feature in facebook app


I would like to implement the similar feature as in the facebook iPad app in which the text can be added to an image as in the below image.

image when unzoomed

I can add a view like this with the text in the imageview, but don't know how to keep the size of the added view like in the below image when its zoomed in or out (like pins in mapview)?

zoomed image

Can some one suggest me implement like in the above facebook tagging feature in my app? Thanks in advance.


Solution

  • You should put your image in a scrollView to be able to zoom it. Your tags are views added on the [scrollView superView], so you can zoom the image and your tags keep the same size. Then with a bit of logic and the convertPoint methods of UIView you should retrieve the coordinate of the anchor in the resized image.

    - (CGPoint)convertPoint:(CGPoint)point toView:(UIView *)view
    

    It's not a fully baked answer but you should have steps. Maybe you can also find some open source implementation to use or inspirational