禁用UIPageViewController Swipe - Swift
问题描述:
在我的项目中,我使用UIPageViewController在5个子UIViewController之间滑动。在一些子视图控制器中,我需要禁用UIPageViewController的轻扫手势,因此当用户轻扫时它不会更改为其他视图。 那么我如何禁用从子视图控制器刷卡?禁用UIPageViewController Swipe - Swift
欣赏的help..thanks
答
在你的网页浏览器,添加以下
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)
时child1正在呈现。 userInteraction = false –