Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/ios/104.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/opencv/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Ios 如何在swift中阻止UIPageViewController的滑动手势?_Ios_Swift_Uipageviewcontroller - Fatal编程技术网

Ios 如何在swift中阻止UIPageViewController的滑动手势?

Ios 如何在swift中阻止UIPageViewController的滑动手势?,ios,swift,uipageviewcontroller,Ios,Swift,Uipageviewcontroller,如何阻止UIPageViewController的滑动手势 pageViewController.view.isUserInteractionEnabled = false private func setupPageController() { pageViewController = UIPageViewController(transitionStyle:.pageCurl, navigationOrientation: .horizontal, options: nil)

如何阻止
UIPageViewController的滑动手势

pageViewController.view.isUserInteractionEnabled = false

private func setupPageController() {
    pageViewController = UIPageViewController(transitionStyle:.pageCurl, navigationOrientation: .horizontal, options: nil)
    pageViewController.delegate = self
    pageViewController.dataSource = nil
    pageViewController.view.isUserInteractionEnabled = false



    viewControllers = [
        storyboard!.instantiateViewController(withIdentifier: "MyProfile"),
        storyboard!.instantiateViewController(withIdentifier: "Sync"),
        storyboard!.instantiateViewController(withIdentifier: "Assistance"),
        storyboard!.instantiateViewController(withIdentifier: "ChangePassword"),
        storyboard!.instantiateViewController(withIdentifier: "ContactUs"),
        storyboard!.instantiateViewController(withIdentifier: "SpeedTest"),
        storyboard!.instantiateViewController(withIdentifier: "Help")

    ]

    pageViewController.setViewControllers([viewControllerAtIndex(0)!], direction: .forward, animated: true, completion: nil)
    pageViewController.dataSource = self



    addChildViewController(pageViewController)
    view.addSubview(pageViewController.view)

    pageViewController!.view.frame = CGRect(x: 0, y:110, width: view.bounds.width, height: view.bounds.height - 70)//view.bounds
    pageViewController.didMove(toParentViewController: self)

    // Add the page view controller's gesture recognizers to the view controller's view so that the gestures are started more easily.

    // view.gestureRecognizers = pageViewController.gestureRecognizers
}

您可以使用下面的扩展来启用或禁用
swipgesture

extension UIPageViewController {

    func enableSwipeGesture() {
        for view in self.view.subviews {
            if let subView = view as? UIScrollView {
                subView.isScrollEnabled = true
            }
        }
    }

    func disableSwipeGesture() {
        for view in self.view.subviews {
            if let subView = view as? UIScrollView {
                subView.isScrollEnabled = false
            }
        }
    }
}

可能重复使用此解决方案但不起作用。请分享您遇到的确切问题。根据您的问题,这似乎与另一个问题类似。禁用数据源会导致问题我无法管理内容页面之间的导航,其中每个页面都由子视图控制器管理。