Restrict UIPageViewController (with TransitionStyleScroll) pan gesture to a certain area

后端 未结 2 1622
感动是毒
感动是毒 2021-01-18 12:19

In my app I have a RootPageViewController which contains the UIPageViewController and one or more DetailPageViewController with a UITableView as a childview.



        
2条回答
  •  暗喜
    暗喜 (楼主)
    2021-01-18 13:00

    My solution in Swift:

    let myview = UIView(frame: CGRect(x:0, y:0, width:320, height:320))
    //dummy view that defines the area where the gesture works
    self.view.addSubview(myview)
    
    for x in self.pageViewController!.view.subviews 
    { if x is UIScrollView
      { myview.addGestureRecognizer(x.panGestureRecognizer) } 
    }
    

提交回复
热议问题