如何在ZUUIRevealController中制作tableview响应平移手势

时间:2012-06-10 08:57:35

标签: iphone ios

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

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

[self.view addGestureRecognizer:recognizer];

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

如何让它像Path2一样工作:水平平移是显示,垂直方向就像普通的桌面视图一样?

1 个答案:

答案 0 :(得分: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;
}