I'm trying to assign the UIPanGestureRecognizer of a UIPageViewController to a different (custom) view, so that the pan gesture, for page switching, only works for a certain area of the screen. The code is basically the following:
let testView = UIView(frame: CGRect(x: 0, y:self.view.frame.height/2, width: 320, height: self.view.frame.height/2))
self.view.addSubview(testView)
for gr in self.pageViewController!.view.subviews[0].gestureRecognizers! {
if gr.isKindOfClass(UIPanGestureRecognizer) {
testView.addGestureRecognizer(gr)
}
}
The problem is that the "next" view controller is not immediately visible when doing the pan, on first pan it appears the current view controller (the first one) is the only one inside PageViewController, it's only after ending the pan and doing a second pan that the next view controller appears.
Note that without assigning the UIPanGesture to a different view, the PageViewController works as expected with the next view controller visible since first pan.
Why do I want to do this? I need to add a subview to the view controllers inside the PageViewController that does not "pan" the PageViewController when the user gestures on top of it.