如何获得对触摸视图的 UIViewController 的引用?
我在 UIViewController 的视图上使用 UIPanGestureRecognizer。这是我初始化它的方式:
TaskUIViewController *thisTaskController = [[TaskUIViewController alloc]init];
[[self view]addSubview:[thisTaskController view]];
UIPanGestureRecognizer *panRec = [[UIPanGestureRecognizer alloc]initWithTarget:self action:@selector(handlePan:)];
[[thisTaskController view] addGestureRecognizer:panRec];
在使用手势识别器触发的触发动作中,我可以使用recognizer.view从参数中获取视图
- (IBAction)handlePan:(UIPanGestureRecognizer *)recognizer {
UIView *touchedView = [[UIView alloc]init];
touchedView = (UIView*)[recognizer view];
...
}
但是我真正需要的是所触摸视图的底层 UIViewController 。如何获取对包含此视图而不是仅 UIView 的 UIViewController 的引用?