Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

lexk

macrumors newbie
Original poster
Aug 8, 2010
17
0
The problem I'm looking to overcome at the moment is trying to use the minimum (25.1751) and maximum (81) values of a UISlider as the minimum and maximum x coordinates of the grey UIView.
In other words, can I make the left edge of the UIView output 25.1751 and the right edge output 81?

The values of the sliders aren't default on account of converting them to frequency values for an oscillator, and currently the values outputted by the UIView are outside of the range I want. I've tried reducing the maximum output of the UIView using math formulas but I can't raise the minimum.
I hope that made some sense!

Here's where I'm at with the code so far and thanks in advance for any help!
Code:
- (IBAction)sawXYPad:(UIPanGestureRecognizer *)trigger {
    float sawpadHeight = sawxyview.bounds.size.height;
    float sawpadWidth = sawxyview.bounds.size.width;
    CGPoint location = [trigger locationInView:sawxyview];

    if ((location.y >= 0) && (location.y < sawpadHeight) && (location.x >= 0) && (location.x < sawpadWidth)) {
        float maxX = sawPSlider.maximumValue;
        float minX = sawPSlider.minimumValue;
        float sawPitchXY = (location.x > minX) && (location.x < maxX);
        sawPSlider.value = sawPitchXY;
        [PdBase sendFloat:sawPitchXY toReceiver:@"saw_pitch"];
    }
}

2b2q2u.png
 
If I am understanding correctly, you could take the x coordinate of the location CGPoint. You would then do

Code:
float position = (location.x/(81-25.1751)) + 25.1751;
 
If I am understanding correctly, you could take the x coordinate of the location CGPoint. You would then do

Code:
float position = (location.x/(81-25.1751)) + 25.1751;

Thank you, this is great for setting the lowest/left x coordinate but then how would I go about setting the highest/right side?
 
I am a bit confused. this line should give you the value of the finger touch between your minimum and maximum. I guess I am misunderstanding what you are trying to do.
 
I am a bit confused. this line should give you the value of the finger touch between your minimum and maximum. I guess I am misunderstanding what you are trying to do.

My mistake - you were right, I just edited it to
Code:
float position = (location.x/(41.725-25.1751)) + 25.1751;
to help scale it within the UIView.
Thanks so much for your help!
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.