Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/swift/17.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Ios 使PanGesture成为滑块_Ios_Swift_Slider_Gesture_Percentage - Fatal编程技术网

Ios 使PanGesture成为滑块

Ios 使PanGesture成为滑块,ios,swift,slider,gesture,percentage,Ios,Swift,Slider,Gesture,Percentage,我把PanGuesture作为滑块制作,下面是响应函数: func respondsToPenGesture(sender: UIPanGestureRecognizer) { if (sender.state == UIGestureRecognizerState.Began) { if noFilterEffectButton.selected == false { startPanLocation = sender.locationInVie

我把PanGuesture作为滑块制作,下面是响应函数:

func respondsToPenGesture(sender: UIPanGestureRecognizer) {
    if (sender.state == UIGestureRecognizerState.Began) {
        if noFilterEffectButton.selected == false {
            startPanLocation = sender.locationInView(self.newEffectView)
            persentageNumber.text = String(startNumber)
            persentageNumber.hidden = false
        }
    } else if (sender.state == UIGestureRecognizerState.Changed) {
        let stopLocation = sender.locationInView(self.newEffectView)
        let abscissaChange = stopLocation.x - startPanLocation!.x
        if newEffectView.hidden == false {
            if abs(abscissaChange) > 0 {
                if noFilterEffectButton.selected == false{
                    if let effectCurrent = self.currentEffect {
                        effectCurrent.adjustParams(CGFloat(abscissaChange/6))
                    }
                }
            }
            if noFilterEffectButton.selected == false {
                var printChangingNumber = startNumber + Int(abscissaChange)
                if printChangingNumber > 100 {
                    printChangingNumber = 100
                } else if printChangingNumber < 0 {
                    printChangingNumber = 0
                }

                persentageNumber.text = String(printChangingNumber)
            }
        }                         
    } else if (sender.state == UIGestureRecognizerState.Ended) {
        let stopLocation = sender.locationInView(self.newEffectView)
        let abscissaChange = stopLocation.x - startPanLocation!.x
        startNumber = startNumber + Int(abscissaChange)
        if startNumber > 100 {
            startNumber = 100
        } else if startNumber < 0 {
            startNumber = 0
        }

        dispatch_after(dispatch_time(DISPATCH_TIME_NOW, Int64(0.5*Double(NSEC_PER_SEC))), dispatch_get_main_queue()) {             
            self.persentageNumber.text = String(self.startNumber)
            self.persentageNumber.hidden = true

        }
    }
}
我覆盖这个函数的唯一效果是:

override func adjustParams(value: CGFloat) {
    super.adjustParams(value)
    lastAutValueChange = lastAutValueChange + value/200
    lastIntensityChange = lastIntensityChange + value/200
    var currentAutValue = lastAutValueChange
    var currentIntValue = lastIntensityChange

    currentIntValue = currentIntValue < -1.0 ? -1.0 : currentIntValue
    //value = value > 1.0 ? 1.0 : value
    //autValue = value < -1.0 ? -1.0 : autValue

    if (currentIntValue >= 0) {
        currentIntValue = 1.0
    } else {
        currentIntValue += 1
    }
    if (currentAutValue <= 0) {
        currentAutValue = 0
    } else {
        if currentAutValue > 1 {
            currentAutValue = 1
        }
    }
    print(currentIntValue)
    print(currentAutValue)


    self.autoTuneModule.setIntensity(Float(currentIntValue))
    self.audioUnit.finalMix = Double(currentAutValue)
}
覆盖函数调整参数(值:CGFloat){
超级调整参数(值)
lastAutValueChange=lastAutValueChange+value/200
lastIntensityChange=lastIntensityChange+值/200
var currentAutValue=lastAutValueChange
var currentIntValue=lastIntensityChange
currentIntValue=currentIntValue<-1.0?-1.0:currentIntValue
//值=值>1.0?1.0:值
//autValue=值<-1.0?-1.0:autValue
如果(currentIntValue>=0){
currentIntValue=1.0
}否则{
currentIntValue+=1
}
如果(当前值)为1{
currentAutValue=1
}
}
打印(currentIntValue)
打印(当前值)
自调谐模块设置强度(浮动(currentIntValue))
self.audioUnit.finalMix=双精度(当前值)
}
测试答案与屏幕上显示的精确更改和百分比数不匹配。我如何更改我的函数以使它们彼此匹配


(顺便说一句,我想做一些类似Prisma中的滑块的事情,如果有类似的事情,请告诉我)。

我已经有了使它们匹配的方法,制作另一个变量来打印并将其发送到adjustParams().我已经有办法使它们匹配,制作另一个要打印的变量并将其发送到adjustParams()。
override func adjustParams(value: CGFloat) {
    super.adjustParams(value)
    lastAutValueChange = lastAutValueChange + value/200
    lastIntensityChange = lastIntensityChange + value/200
    var currentAutValue = lastAutValueChange
    var currentIntValue = lastIntensityChange

    currentIntValue = currentIntValue < -1.0 ? -1.0 : currentIntValue
    //value = value > 1.0 ? 1.0 : value
    //autValue = value < -1.0 ? -1.0 : autValue

    if (currentIntValue >= 0) {
        currentIntValue = 1.0
    } else {
        currentIntValue += 1
    }
    if (currentAutValue <= 0) {
        currentAutValue = 0
    } else {
        if currentAutValue > 1 {
            currentAutValue = 1
        }
    }
    print(currentIntValue)
    print(currentAutValue)


    self.autoTuneModule.setIntensity(Float(currentIntValue))
    self.audioUnit.finalMix = Double(currentAutValue)
}