I have a UIScrollView with 7 UIButtons on it.
5 buttons are working fine but the other two (which the scroll view needs to be scrolled for the buttons to be reached) doesn't work most of the times (if I tap a lot of times they sometimes work but most of the time they don't).
I've tried to increase the contentSize and the buttons still don't work.
I've tried to change the x position of the buttons and they both work so the problem is definitely about the position in the scrollView.
Code:
scrollView:
self.buttonsScrollView = UIScrollView(frame: self.bounds)
self.buttonsScrollView?.frame.origin.y = (self.window?.frame.size.height)! - self.bounds.size.height
self.buttonsScrollView?.showsHorizontalScrollIndicator = false
self.buttonsScrollView?.canCancelContentTouches = true
self.buttonsScrollView?.clipsToBounds = false
buttons (x7)
let buttonX = UIButton(frame: CGRect(x: previousButton.frame.origin.x + spaceBetweenButtons, y: buttonsYPosition, width: buttonSize, height: buttonSize))
buttonX.setImage(UIImage(named: "buttonsXImage"), for: UIControlState())
buttonX.tag = 0
buttonX.addTarget(self, action: #selector(buttonPressed), for: .touchUpInside)
let buttonXRecognizer = UIPanGestureRecognizer(target: self, action: #selector(didDragButton))
buttonX.addGestureRecognizer(buttonXRecognizer)
Any ideas what can be the problem?
Thank you!