Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>I like your idea of keeping all the pins in a view dedicated to pins (iconsView), but I decided to just add them as subviews of what you called imageViewMap.</p> <p>Import the QuartzCore.framework file to your project.</p> <p>Call your view controller MyViewController.</p> <pre><code>#import &lt;QuartzCore/QuartzCore.h&gt; @interface MyViewController : UIViewController &lt;UIScrollViewDelegate&gt; @property (retain) UIScrollView *scrollView; @property (retain) UIImageView *imageView; </code></pre> <p>// and so on</p> <pre><code>@implementation MyViewController @synthesize scrollView; @synthesize imageView; </code></pre> <p>I'll assume you have a pin view or a view controller called DropPinViewController. If you're just using an image, it can be a UIImageView, but my pins have labels, so I used a xib. The pin should point to the bottom center of the xib because we're going to put an anchor point there.</p> <p>In your viewDidLoad of your MyViewController, add your pin views as subviews of imageView. Add the imageView as a subview to the scrollView. Set the content size of scrollView.</p> <pre><code>scrollView.delegate = self; </code></pre> <p>Use these delegate methods:</p> <pre><code>- (void)scrollViewDidZoom:(UIScrollView *)aScrollView { for (UIView *dropPinView in imageView.subviews) { CGRect oldFrame = dropPinView.frame; // 0.5 means the anchor is centered on the x axis. 1 means the anchor is at the bottom of the view. If you comment out this line, the pin's center will stay where it is regardless of how much you zoom. I have it so that the bottom of the pin stays fixed. This should help user RomeoF. [dropPinView.layer setAnchorPoint:CGPointMake(0.5, 1)]; dropPinView.frame = oldFrame; // When you zoom in on scrollView, it gets a larger zoom scale value. // You transform the pin by scaling it by the inverse of this value. dropPinView.transform = CGAffineTransformMakeScale(1.0/scrollView.zoomScale, 1.0/scrollView.zoomScale); } - (UIView *)viewForZoomingInScrollView:(UIScrollView *)scrollView { return imageView; } </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload