读取UISlider的最大值和最小值

时间:2013-04-21 13:14:01

标签: ios objective-c uislider

有没有办法读取Interface Builder的属性检查器中声明的UISlider的最大值和最小值? 我想将这些值用作UIView中X坐标的范围,我不知道该怎么做。

- (IBAction)sineXYPad:(UIPanGestureRecognizer *)trigger {
    float sinepadHeight = sinexyview.bounds.size.height;
    float sinepadWidth = sinexyview.bounds.size.width;
    CGPoint location = [trigger locationInView:sinexyview];

    if ((location.y >= 0) && (location.y < sinepadHeight) && (location.x >= 0) && (location.x < sinepadWidth)) {
        float maxX = sinePSlider.maximumValue;
        float minX = sinePSlider.minimumValue;
        float sinePitchXY = (location.x > minX) && (location.x < maxX);
        sinePSlider.value = sinePitchXY;
        [PdBase sendFloat:sinePitchXY toReceiver:@"sine_pitch"];
    }
}

这是我的用户界面:

enter image description here

1 个答案:

答案 0 :(得分:0)

尝试:

[sinePSlider setMinimumValue:sinexyview.bounds.origin.x];
[sinePSlider setMaximumValue:sinexyview.bounds.size.width];