make one UISlider update when another UISlider is changed

41 Views Asked by At

I have an app in which I an using one slider to zoom in on an image (RealImage) from 1x to 2x. I am using this code to do so.

- (IBAction) sliderValueChanged:(UISlider *)sender {
  zoomSlider.minimumValue = 1;
  zoomSlider.maximumValue = 2;
  see = [zoomSlider value];
  ax2 = xSlider.value;
  self.RealImage.frame = CGRectMake(12-(ax2),138-(ay2),740*see,850*see);
}

I have another Slider to pan to the right and left. I am using this code to do that.

- (IBAction) xsliderValueChanged:(UISlider *)sender {
  xSlider.minimumValue = 0;
  xSlider.maximumValue = (740*subtract)+1;
  ax2 = xSlider.value;
  self.RealImage.frame = CGRectMake(12-(ax2),138-(ay2),740*see,850*see);
}

When I move the zoomSlider I want to update the xSlider and keep the image in the same relative position right to left.
the image is 740 pixels wide and start at a +12 x coordinate. As it is now when I zoom in the image enlarges but the slider stays stationary. Then when I go back to the xSlider the slider jumps to another position and so does the picture.

Is there someway to do what I want I'm sure there is. I don't want to use pinch and swipe gestures because this is a drawing app and I am already using touch recognizers.

Any suggestions would be welcome.

1

There are 1 best solutions below

0
On

So I finally figured this out. I changed the slider maximunValue to 740 and then the image frame to 12-(ax2*subtract) where subtract = see-1; Seems to work ok now.