我在我的应用程序中使用ECSlidingViewController,它包含的拥有GestureRecognizer
看起来像:
[self.view addGestureRecognizer:self.slidingViewController.panGesture];
它阻止了 TableView 的滚动。当我删除该行滚动工作正常。我的方法有什么问题?
注意:TableView
是导航控制器的一部分。我正在使用StoryBoards。
我在我的应用程序中使用ECSlidingViewController,它包含的拥有GestureRecognizer
看起来像:
[self.view addGestureRecognizer:self.slidingViewController.panGesture];
它阻止了 TableView 的滚动。当我删除该行滚动工作正常。我的方法有什么问题?
注意:TableView
是导航控制器的一部分。我正在使用StoryBoards。
您需要将 添加UIGestureRecognizer
到 的视图,而UINavigationController
不是UITableView
.
一种方法是创建一个UINavigationController
子类来处理手势识别器的创建和 ECSlidingViewController 的 underLeft(或 underRight)视图控制器的实例化:
// MyNavigationController.h
@interface MyNavigationController : UINavigationController
@end
// MyNavigationController.m
@implementation MyNavigationController
- (void)viewWillAppear:(BOOL)animated
{
[super viewWillAppear:animated];
if (![self.slidingViewController.underLeftViewController isKindOfClass:[MyLeftMenuViewController class]]) {
self.slidingViewController.underLeftViewController = [self.storyboard instantiateViewControllerWithIdentifier:@"MenuViewController"];
}
[self.view addGestureRecognizer:self.slidingViewController.panGesture];
}
@end
打开 Storyboard Editor,选择导航控制器并将 Identity Inspector 的 Custom Class 字段设置为MyNavigationController
(而不是默认值UINavigationController
)。
我尝试了您建议的方法,但是在 UINavigationController 的子类中插入手势识别器不起作用。奇怪的是,把理论上等价的
[self.navigationController.view addGestureRecognizer:self.slidingViewController.panGesture];
在 TableviewControllerviewWillAppear:
方法中可以代替。
尝试
[self.parentView.view addGestureRecognizer:self.slidingViewController.panGesture];
在 viewWillAppear 上的 TableViewController