I have a weird bug where a buttons touchUpInside
does not work as it should. I have two buttons using the same code
@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])
However the previous
button only works when I drag after tapping. as opposed to the next
button that works simply by tapping. Why am I getting this weird behavior in this one button?
I would like to add.touchDragOutside
to my previous button, but I can't because then the button does not work