我遇到了UIPageViewController问题。我做了什么? 1.在pageViewController上,您可以向左,向右滑动以更改VC 2.增加横向菜单。添加横向菜单时,我创建了pangesture识别器并将其添加到pageContentVC(因此我可以拖动pageContentVC以关闭侧边栏菜单)
var menuViewController: UIViewController! {
didSet {
self.exitPanGesture = UIPanGestureRecognizer()
self.exitPanGesture.addTarget(self, action:"handleOffstagePan:")
// self.exitPanGesture.view?.userInteractionEnabled = false
self.sourceViewController.view.addGestureRecognizer(self.exitPanGesture)
}
}
这里我将pageContentVC设置为transitionManager的sourceVC:
func resetToMainPage(index: Int!) {
/* Getting the page View controller */
mainPageViewController = self.storyboard?.instantiateViewControllerWithIdentifier("MainPageViewController") as UIPageViewController
self.mainPageViewController.dataSource = self
self.mainPageViewController.delegate = self
let pageContentViewController = self.viewControllerAtIndex(index)
self.transtionManger.sourceViewController = pageContentViewController // adding swipe to the pageContentViewControlle in order to close menu
self.mainPageViewController.setViewControllers([pageContentViewController!], direction: UIPageViewControllerNavigationDirection.Forward, animated: true, completion: nil)
self.mainPageViewController.view.frame = CGRectMake(0, 102, self.view.frame.width, self.view.frame.height)
self.addChildViewController(mainPageViewController)
self.view.addSubview(mainPageViewController.view)
self.mainPageViewController.didMoveToParentViewController(self)
}
关闭菜单后,我禁用了pangesture识别器。 `var presentingP:Bool!{ didSet { 如果presentP == true { //仅在显示menucontroller视图时启用手势识别器
self.exitPanGesture.view?.userInteractionEnabled = true
}else{
// disable gesture recognizer when menu is not presented
self.exitPanGesture.view?.userInteractionEnabled = false
isMenuVisible = false
}
}
} `Sofar,我可以向左滑动,向右滑动以改变VC。 问题是我无法在VC上滚动tableView。禁用pageContentVC手势后,除了向右和向左滑动(更改VC)外,一切都会变为禁用状态。问题:如何在一个视图中保留两个gestureRecognizer并在它们之间切换?
答案 0 :(得分:2)
您可以使用enabled
UIGestureRecognizer
属性禁用您不想使用的属性并启用另一个属性。