我想在用户使用 map 视图移动时添加一些逻辑,例如,他进行平移touch .但是,当我添加手势识别器并想要记录touch 时,什么都没有发生.当我在另一个视图控制器中try 并将识别器添加到控制器的视图中时,它工作正常.
下面是我的代码(map view是application delegate的一个属性,因为即使它不可见,我也需要用它做一些其他事情):
- (void)viewDidLoad
{
...
UIPanGestureRecognizer *panGesture = [[UIPanGestureRecognizer alloc] initWithTarget:self action:@selector(showPan)];
[appDelegate.mapView addGestureRecognizer:panGesture];
[panGesture release];
}
- (void)showPan
{
NSLog(@"pan!");
}
我使用最新的iOS 4.2.1
谢谢你的建议.