UITableView embedded in UIPageViewController (ScrollStyle) cannot be tapped - didSelectRowAtIndexPath not fired

二次信任 提交于 2019-12-07 17:49:41

问题


My architecture of viewcontrollers are:

    mainViewController(full-screen)
             |
             V
   pageViewController(part-of-screen)
         |             |
         V             V
tableViewController1 tableViewController2

Unlike most of existing posts, the UIPageViewController is set to style: UIPageViewControllerTransitionStyleScroll, which means that pageVC.gestureRecognizers is empty, and I can NOT find the tapGuesture to disable.

I've searched the site for a whole afternoon, and find NO solution (most answers are related to the pageCurlStyle). What I've tried includes:

  1. setting the tableViewController.view's delegate to mainViewController, useless
  2. implement gestureRecognizer:shouldReceiveTouch, not even called
  3. pageVC.gestureRecognizers is empty

I haven't tried to do UITouch level things, that will be kind of dirty, and would be the last step to try.

My code is attached below, some explanations:

  1. UIPageViewController* pageVC is a data member of mainViewController)
  2. listVCs contains the UITableViewControllers

the code:

// 3. create page view controller
pageVC = [[UIPageViewController alloc] initWithTransitionStyle:UIPageViewControllerTransitionStyleScroll          navigationOrientation:UIPageViewControllerNavigationOrientationHorizontal options:nil];
pageVC.dataSource = self;
pageVC.delegate = self;
pageVC.doubleSided = NO;
pageVC.view.frame = _viewLayoutRef.frame;

// 3.1 set the VCs into pageVC
NSArray* aVC = @[[listVCs objectAtIndex:0]];
[pageVC setViewControllers:aVC direction:UIPageViewControllerNavigationDirectionForward animated:NO     completion:nil];

// 3.2 hook page view controller
[self addChildViewController:pageVC];
[self.view addSubview:pageVC.view];
[pageVC didMoveToParentViewController:self];

回答1:


From your view hierarchy...Your are feeding the view controllers(UITableViewcontroller) to UIPageViewController right? Instead of UITableViewController you can create UIViewController in which you can add UITableview.



来源:https://stackoverflow.com/questions/24508369/uitableview-embedded-in-uipageviewcontroller-scrollstyle-cannot-be-tapped-di

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!