1

I have a scrollView and two subviews attached in that an imageView and a buttons view which holds some hotspots that have lines to the image view. I want to zoom in / out and move the hotspots accordingly. The problem i have is that i can't keep the hotspots in the place i want and can't find a solution here.

here is my code in viewDidLoad

- (void)viewDidLoad
{
    [super viewDidLoad];

    // set the tag for the image view
    [imageView setTag:ZOOM_VIEW_TAG];

    imageScrollView.delegate = self;

    float sexy = [imageScrollView frame].size.height  / [imageView frame].size.height;
    initialZoom = sexy;
    [imageScrollView setZoomScale:sexy animated:NO];
    [imageScrollView setMinimumZoomScale:sexy];
    [imageScrollView setContentInset:UIEdgeInsetsMake(-30, 0, 0, 0)];
    scaleStart =  imageScrollView.zoomScale;
    buttonView = [[UIView alloc]init];
    buttonView.frame = imageScrollView.frame;

    [imageScrollView addSubview:buttonView];

    button = [UIButton buttonWithType:UIButtonTypeRoundedRect];
    [button addTarget:self
               action:@selector(buttonClicked:)
     forControlEvents:UIControlEventTouchDown];
    [buttonView addSubview:button];

    [button setTitle:@"Button x" forState:UIControlStateNormal];

    button.frame = CGRectMake(200.0, 400.0, 520.0, 150.0);
    imageView.center = self.view.center;
    imageScrollView.maximumZoomScale = MAX_ZOOM_SCALE;

    //setting an orientation notifier
    UIDevice *device = [UIDevice currentDevice];                    //Get the device object
    [device beginGeneratingDeviceOrientationNotifications];         //Tell it to start monitoring the accelerometer for orientation
    NSNotificationCenter *nc = [NSNotificationCenter defaultCenter];    //Get the notification centre for the app
    [nc addObserver:self                                            //Add yourself as an observer
           selector:@selector(orientationChanged:)
               name:UIDeviceOrientationDidChangeNotification
             object:device];    
  }

and i'm trying to implement the rest of my code in

- (void)scrollViewDidZoom:(UIScrollView *)aScrollView 

without any luck using aScrollView.zoomScale property.

and moving the button view in right place. the problem i have is that zoomscale when i zoom in (full zoom in) i get a value of 0.53454 and and when i (full) zoom out i get a value of 0.37261 why is this happening and i don't get again the first value?

how can i do what i want to do?

i want something like google maps when zoom in/out and the place spots keep in place without zooming themselves.

fizampou
  • 717
  • 2
  • 10
  • 29

1 Answers1

0

How about this?

If you want something keep it's own scale while zooming, you can make another view that contains it. It's like divide one view to two view. one is taking charge of zooming, and another one is taking charge of handling things which keep scale. This is the why I did.

Wooseong Kim
  • 1,871
  • 2
  • 21
  • 19