禁用UIPageViewController Swipe - Swift

问题描述:

在我的项目中,我使用UIPageViewController在5个子UIViewController之间滑动。在一些子视图控制器中,我需要禁用UIPageViewController的轻扫手势,因此当用户轻扫时它不会更改为其他视图。 那么我如何禁用从子视图控制器刷卡?禁用UIPageViewController Swipe - Swift

欣赏的help..thanks

+0

时child1正在呈现。 userInteraction = false –

在你的网页浏览器,添加以下

override func viewDidLoad(){ 
    super.viewDidLoad() 
    NSNotificationCenter.defaultCenter().addObserver(self, selector: #selector(yourpageviewcontroller.enableSwipe(_:)), name:"enableSwipe", object: nil) 
    NSNotificationCenter.defaultCenter().addObserver(self, selector: #selector(yourpageviewcontroller.disableSwipe(_:)), name:"disableSwipe", object: nil) 

} 
func disableSwipe(notification: NSNotification){ 
    self.dataSource = nil 
} 

func enableSwipe(notification: NSNotification){ 
    self.dataSource = self 
} 

在你的孩子的视图控制器,你可以通过以下张贴通知。

NSNotificationCenter.defaultCenter().postNotificationName("enableSwipe", object: nil) 

OR

NSNotificationCenter.defaultCenter().postNotificationName("disableSwipe", object: nil) 
+0

嗨,它的滑动工作,但它也阻止了上下滚动,因为我的孩子有uitableview。谢谢 – Voyager

+0

请检查您的子视图的'用户交互已启用',也在您的tableView,请确保滚动已启用复选框被选中 – Rurouni

+0

事实证明,我的逻辑检查偏移其错误。所以我接受了答案。谢谢! – Voyager