UIPanGestureRecognizer 클래스를 사용하여 y 축을 위아래로 드래그하는 UIButton이 있습니다. 나는 수직 기능을 위해 UISlider 대신 이것을 사용하고있다. 0에서 1 사이의 모든 float 값을 캡처하려면 UISlider처럼 단추를 위아래로 드래그하여 최소값 0에서 최대 1로 제한하십시오.UIPanGestureRecognizer를 사용하여 y 값에서 0과 1 사이의 float 값을 얻는 방법
현재 코드 isn ' 정확한 값을 포착합니다. 나는이 문제를 해결할 수있는 방법 : 나는 비슷한 달성하기 위해 locationOfTouch
(하지translationInView
)과 제스처의 다른 state
에 의존
- (void)wasDragged:(UIPanGestureRecognizer *)recognizer {
CGPoint translation = [recognizer translationInView:self.view];
CGPoint newCenter = CGPointMake(recognizer.view.center.x,recognizer.view.center.y + translation.y);
//range is 139 pixels
//i tried dividing 1/139 to get the increment using pixels
if(newCenter.y >= 126 && newCenter.y <= 265)
{
currentMainVolValue = currentMainVolValue - 0.00714285714286;
recognizer.view.center = newCenter;
[recognizer setTranslation:CGPointZero inView:self.view];
}
}
당신은 최소 수동 UI 슬라이더의 최대 값은, 다음 분할을 설정할 수 준다 당신이 원하는 감도에 따라 플로트를 얻으십시오. – ManicMonkOnMac