2

导航栏可以响应 ZUUIRevealController 中的平移手势。但是我想让frontViewController的整个屏幕响应像Path2这样的平移手势,所以我写了这样的代码:

UIPanGestureRecognizer *recognizer = [[UIPanGestureRecognizer alloc] initWithTarget:self.navigationController.parentViewController action:@selector(revealGesture:)];

[self.view addGestureRecognizer:recognizer];

除了在 UITableViewController 中它工作正常。当我将它放在 UITableViewController 的 viewDidLoad 方法中时,表格无法响应任何其他平移手势,因此无法滚动。

我怎样才能让它像 Path2 一样工作:水平平移是为了显示,垂直平移是为了像普通的表格视图一样工作?

4

1 回答 1

6

有一个简单的解决方案:

在frontViewController中:

- (void)viewDidLoad
{
...

    UIPanGestureRecognizer *recognizer = [[UIPanGestureRecognizer alloc] initWithTarget:self.navigationController.parentViewController action:@selector(revealGesture:)];

    recognizer.delegate = self;

...
}

- (BOOL)gestureRecognizer:(UIGestureRecognizer *)gestureRecognizer shouldRecognizeSimultaneouslyWithGestureRecognizer:(UIGestureRecognizer *)otherGestureRecognizer
{
    return TRUE;
}
于 2012-07-30T11:27:17.303 回答