Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/ios/96.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 手势不适用于包含UITableViewController的UIPageViewController_Ios_Swift_Uitableview_Uigesturerecognizer_Uipageviewcontroller - Fatal编程技术网

Ios 手势不适用于包含UITableViewController的UIPageViewController

Ios 手势不适用于包含UITableViewController的UIPageViewController,ios,swift,uitableview,uigesturerecognizer,uipageviewcontroller,Ios,Swift,Uitableview,Uigesturerecognizer,Uipageviewcontroller,我正在尝试为我的应用程序实现类似通知中心的功能: 有一个UIPageViewController,因为我想让左/右滑动手势正常工作,在里面我需要显示4个UITableViewControllers。顶部有一个UISegmentedCotrol显示“选择了哪个选项卡” 除了用于更改页面的滑动手势之外,一切都正常工作,就好像TableView正在捕获手势而不让PageView完成它的工作一样 我不需要我的TableView是可编辑的,因为它们只是来自网站的文章。只有didSelectRowAt(in

我正在尝试为我的应用程序实现类似通知中心的功能:

有一个
UIPageViewController
,因为我想让左/右滑动手势正常工作,在里面我需要显示4个
UITableViewControllers
。顶部有一个
UISegmentedCotrol
显示“选择了哪个选项卡”

除了用于更改页面的滑动手势之外,一切都正常工作,就好像TableView正在捕获手势而不让PageView完成它的工作一样

我不需要我的TableView是可编辑的,因为它们只是来自网站的文章。只有
didSelectRowAt(indexPath)
就足以完成我需要做的任何事情(转到“articleViewController”)


如果有人知道如何让
UIPageViewController
的手势与
TableViewController
一起工作,请告诉我。谢谢


var pageviewController=UIPageViewController()


谢谢,但这在我的情况下不起作用…我正在从序列图像板实例化PageViewController,并在代码中实例化每个TableViewController。我希望保留默认行为(能够在“页面”之间以可视方式滑动),如果我不使用TableViewController,这会起作用(甚至当从普通UIViewController切换到UITableViewController时)但不是相反的方式谢谢,但这在我的情况下不起作用…我正在从Storyboard中实例化PageViewController,并在代码中实例化每个TableViewController。我希望保留默认行为(能够在“页面”之间直观地滑动),如果我不使用TableViewController(甚至在从普通UIViewController切换到UITableViewController时),该选项也可以使用但不是相反的方法。我建议任何有类似情况的人使用图书馆,因为它会处理所有的麻烦。我建议任何有类似情况的人使用图书馆,因为它会处理所有的麻烦。
pageviewController = UIPageViewController(transitionStyle: .scroll, navigationOrientation: .horizontal, options: nil)

    pageviewController.view.frame = CGRect(x: 0, y: 0, width: 320 , height: 568)

    pageviewController.setViewControllers([arrayControllers[0]], direction: .forward, animated: false, completion: nil)

    addChildViewController(pageviewController)
    viewToAdd.addSubview(pageviewController.view)
    pageviewController.didMove(toParentViewController: self)

let swipeRight = UISwipeGestureRecognizer(target: self, action: #selector(self.respondToSwipeGesture))
    swipeRight.direction = UISwipeGestureRecognizerDirection.right

    self.view.addGestureRecognizer(swipeRight)
    let swipeLeft = UISwipeGestureRecognizer(target: self, action: #selector(self.respondToSwipeGesture))
    swipeLeft.direction = UISwipeGestureRecognizerDirection.left
    self.view.addGestureRecognizer(swipeLeft)

func respondToSwipeGesture(gesture: UIGestureRecognizer) {
    if let swipeGesture = gesture as? UISwipeGestureRecognizer {
        switch swipeGesture.direction {
        case UISwipeGestureRecognizerDirection.right:
            //right view controller

            print("Swipe Right")

        case UISwipeGestureRecognizerDirection.left:
            //left view controller

            print("Swipe left")

        default:
            break
        }
    }
}