ボタンtouchUpInside
が正常に動作しない不思議なバグがあります。私はタップした後にドラッグするとprevious
ボタンのみ動作しますが、同じコードスウィフトボタンが正しく機能していませんか?
@IBOutlet weak var previousIBO: UIButton!
@IBOutlet weak var nextIBO: UIButton!
@IBAction func buttonDown(sender: AnyObject) {
nextSingleFire()
timer = Timer.scheduledTimer(timeInterval: 0.2, target: self, selector:#selector(nextFire), userInfo: nil, repeats: true)
}
@IBAction func buttonUp(sender: AnyObject) {
timer.invalidate()
}
nextIBO.addTarget(self, action:#selector(buttonDown(sender:)), for: .touchDown)
nextIBO.addTarget(self, action:#selector(buttonUp(sender:)), for: [.touchUpInside, .touchUpOutside, .touchDragOutside])
previousIBO.addTarget(self, action:#selector(buttonDown(sender:)), for: .touchDown)
previousIBO.addTarget(self, action:#selector(buttonUp(sender:)), for: [.touchUpInside, .touchUpOutside])
を使用して2つのボタンがあります。単にタップするだけで動作するnext
ボタンとは対照的です。なぜ私はこの1つのボタンでこの奇妙な動作を取得していますか?
は、私は私の前のボタンに.touchDragOutside
を追加したいと思いますが、私はあなただったら、私はあなたの機能に@IBActionを除去することにより、起動したい