我正在尝试在 MKMapView 上捕获平移和“滚动结束”。使用手势识别器可以轻松实现平移。但是,MKMapView 似乎没有在 iOS 6 中实现 UIScrollViewDelegate。这使得解决方案在Is there way to limit MKMapView 最大缩放级别?不行。
想法?理想情况下,我会像这样利用 UIScrollViewDelegate :
-(void)scrollViewDidEndDecelerating:(UIScrollView *)scrollView {
if ([super respondsToSelector:@selector(scrollViewDidEndDecelerating:)]) {
[super scrollViewDidEndDecelerating:scrollView];
}
[self.myDelegate mapDidFinishPanning:self];
}
-(void)scrollViewDidEndDragging:(UIScrollView *)scrollView willDecelerate: (BOOL)decelerate {
if ([super respondsToSelector:@selector(scrollViewDidEndDragging:)]) {
[super scrollViewDidEndDragging:scrollView];
}
if(!decelerate) {
[self.myDelegate mapDidFinishPanning:self];
}
}
-(void)scrollViewWillBeginDragging:(UIScrollView *)scrollView {
if ([super respondsToSelector:@selector(scrollViewWillBeginDragging:)]) {
[super scrollViewWillBeginDragging:scrollView];
}
[self.myDelegate mapDidBeginPanning:self];
}
在扩展 MKMapView 的类中
@interface MyMapView : MKMapView <UIScrollViewDelegate, UIGestureRecognizerDelegate>
但这在 iOS 6 中不起作用。我在 MKMapViewDelegate 中看不到任何足够的东西。