Note that there are some explanatory texts on larger screens.

plurals
  1. POUIScrollView ImageView with pins on top
    text
    copied!<p>I have a <code>UIScrollView</code> which has a <code>UIImageView</code>. I want to show pins on this <code>imageView</code>. When I add pins as subviews of the <code>ImageView</code>, everything is great except for when you zoom the scale transform happens on the pins also. I don't want this behavior and want my pins to stay the same.</p> <p>So I choose to add the Pins to another view which sits on top of the ImageView and is also a subview of the <code>UIScrollView</code>. The idea here if you will imagine is to have a layer which hovers over the map and won't scale yet show pins over where I plot them.</p> <p>The pin when added to the layer view don't cale if the <code>ImageView</code> scales. However, the issue then becomes the position of the pins doesn't match the original origin x/y as the <code>ImageView</code> has had a scale transform.</p> <p>Basically this is a custom map of a place with Pins. I am trying to have the Pins float over and not zoom in and out over my ImageView yet remember where I placed them when the zoom happens.</p> <p>Some code:</p> <pre><code>scrollView = [[UIScrollView alloc] initWithFrame:viewRect]; scrollView.delegate = self; scrollView.pagingEnabled = NO; scrollView.scrollsToTop = NO; [scrollView setBackgroundColor:[UIColor clearColor]]; scrollView.clipsToBounds = YES; // default is NO, we want to restrict drawing within our scrollview scrollView.bounces = YES; scrollView.autoresizingMask = UIViewAutoresizingFlexibleHeight; scrollView.indicatorStyle = UIScrollViewIndicatorStyleWhite; imageViewMap = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"image.png"]]; imageViewMap.userInteractionEnabled = YES; viewRect = CGRectMake(0,0,imageViewMap.image.size.width,imageViewMap.image.size.height); //viewRect = CGRectMake(0,0,2976,3928); [scrollView addSubview:imageViewMap]; [scrollView setContentSize:CGSizeMake(viewRect.size.width, viewRect.size.height)]; iconsView = [[UIView alloc] initWithFrame:imageViewMap.frame]; [scrollView addSubview:iconsView]; </code></pre> <p>Code to add Pin later on some event.</p> <pre><code>[iconsView addSubview:pinIcon]; </code></pre> <p>I am stuck in trying tp figure out how to to get my pins to hover on the map without moving when the scale happens.</p>
 

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