In my swift ios app. I use below code to create a circle shape UIView on my screen. Then I add a UILongPressGestureRecognizer to it, keeping the view itself as well as the gestureRecognizer in their respective arrays. Every time user touch and hold onto this view, the code runs again and creates another view and add another UILongPressGestureRecognizer to it.
let x = CGFloat(arc4random_uniform(UInt32(sW-w)))
let y = CGFloat(arc4random_uniform(UInt32(sH-h-10)))+15
circle.append(UIButton())
touch.append(UILongPressGestureRecognizer())
let l = circle.count-1
circle[l].frame = CGRect(x:x, y:y, width:70, height:70)
circle[l].backgroundColor = UIColor.redColor()
circle[l].layer.cornerRadius = w/2
circle[l].clipsToBounds = true
touch[l].addTarget(self, action: "touched:")
touch[l].minimumPressDuration = 0
touch[l].numberOfTouchesRequired = 1
touch[l].numberOfTapsRequired = 0
touch[l].allowableMovement = 0
touch[l].delegate = self
circle[l].addGestureRecognizer(touch[l])
self.view.addSubview(circle[l])
Now when I run the app, I can tap and hold on to the circle view and its state changes to .Began and it also fires .Changed and .Ended statuses up to 5 views. BUT when the 6th view is added, the gesture recognizer does not work on it.
There is nothing in Apple documentation about any maximum number of gestureRecognizers that would work simultaneously. What else could be causing this behaviour?