1

我有一个 UIView 子类,我在其中添加了一个 UIPanGestureRocognizer:

_panGestureRecognizer = [[UIPanGestureRecognizer alloc]
                         initWithTarget:self action:@selector(handlePanGesture:)];
_panGestureRecognizer.maximumNumberOfTouches = 1;
_panGestureRecognizer.delegate = self;
[self addGestureRecognizer:_panGestureRecognizer];

此视图用于包含 UISplitViewController 作为顶级视图/控制器的视图层次结构中。

在 iPad 模拟器中以横向方式对此进行测试时,如果我通过向上/向下/向左启动平移,我的handlePanGesture:方法将按预期调用。但是,如果我通过向右启动平底锅,则不会调用我的handlePanGesture:方法。为什么不?

4

1 回答 1

4

当我写这个问题时,我自己想出了答案:

从 iOS 5 开始的 UISplitViewController 默认会识别向右滑动手势并显示弹出框控制器。这在纵向时很明显,但是在横向时,手势没有明显的效果,因为纵向显示为弹出框的左侧视图始终以横向显示。

解决方案是禁用 UISplitViewController 的滑动手势:

splitViewController.presentsWithGesture = NO;

我不知道是否有办法让这两种手势都起作用。

于 2012-08-16T13:09:31.767 回答