无法点击嵌入在 UIPageViewController (ScrollStyle) 中的 UITableView - didSelectRowAtIndexPath 未触发 [英] UITableView embedded in UIPageViewController (ScrollStyle) cannot be tapped - didSelectRowAtIndexPath not fired
问题描述
我的视图控制器架构是:
My architecture of viewcontrollers are:
mainViewController(full-screen)
|
V
pageViewController(part-of-screen)
| |
V V
tableViewController1 tableViewController2
与大多数现有帖子不同,UIPageViewController 设置为样式:UIPageViewControllerTransitionStyleScroll,这意味着 pageVC.gestureRecognizers 为空,我找不到要禁用的 tapGuesture.
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.
我在网站上搜索了一个下午,没有找到解决方案(大多数答案都与 pageCurlStyle 相关).我尝试过的包括:
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:
- 将tableViewController.view的委托设置为mainViewController,没用
- 实现gestureRecognizer:shouldReceiveTouch,甚至不调用
- pageVC.gestureRecognizers 为空
我还没有尝试做 UITouch 级别的事情,那会有点脏,而且是最后一步尝试.
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:
- 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];
推荐答案
从您的视图层次结构...您正在将视图控制器(UITableViewcontroller
) 提供给 UIPageViewController
正确?您可以创建 UIViewController
而不是 UITableViewController
,您可以在其中添加 UITableview
.
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
.
这篇关于无法点击嵌入在 UIPageViewController (ScrollStyle) 中的 UITableView - didSelectRowAtIndexPath 未触发的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!