我的 View Controller 架构是:
mainViewController(full-screen)
|
V
pageViewController(part-of-screen)
| |
V V
tableViewController1 tableViewController2
与大多数现有帖子不同,UIPageViewController 设置为样式:UIPageViewControllerTransitionStyleScroll,这意味着 pageVC.gestureRecognizers 为空,我找不到要禁用的 tapGuesture。
我在网站上搜索了一个下午,没有找到任何解决方案(大多数答案都与 pageCurlStyle 相关)。我尝试过的包括:
- 将 tableViewController.view 的委托(delegate)设置为 mainViewController,无用
- 实现gestureRecognizer:shouldReceiveTouch,甚至不调用
- pageVC.gestureRecognizers 为空
我还没有尝试做 UITouch 级别的事情,那会有点脏,而且将是尝试的最后一步。
我的代码附在下面,一些解释:
- UIPageViewController* pageVC 是 mainViewController 的数据成员)
- listVCs 包含 UITableViewControllers
代码:
// 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];
最佳答案
从您的 View 层次结构...您正在将 View Controller (UITableViewcontroller
) 提供给 UIPageViewController
对吗?您可以创建 UIViewController
而不是 UITableViewController
,您可以在其中添加 UITableview
。
关于ios - 无法点击嵌入在 UIPageViewController (ScrollStyle) 中的 UITableView - didSelectRowAtIndexPath 未触发,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24508369/