Неуall。我需要些帮助。我使用的是MapKit,当然我的相机可以上下移动(放大和缩小)。
我想在缩放时更改MKMapCamera间距。因此,当相机较低时,间距将很大(~80),而当相机较高时,间距将较小(0)。
这张图片显示了我想做的事情:

我试着创建了一个函数,它可以监控高度并自动改变音高:
cam_timer = [NSTimer scheduledTimerWithTimeInterval: 0.05 target: self selector: @selector (test) userInfo:nil repeats: YES];
- (void) test
{
[debug_lbl_1 setText: [NSString stringWithFormat:@"%f", map.region.span.latitudeDelta]];
map.camera.pitch = 45; // changing pitch
}但当我在该功能中访问摄像头时,它停止了移动。我的意思是…我不能移动,缩放或制作地图上的任何东西,如果我试图从那个功能访问相机。
所以我的问题是:当高度(变焦级别)改变时,我如何制作改变间距的函数?求求你,我非常需要帮助=(
发布于 2017-12-10 02:16:28
在iOS 10及更高版本中,可通过使用MKMapCamera和UIView动画来实现此目的
mapView.camera = MKMapCamera(lookingAtCenter: pinLocation, fromDistance: 2000, pitch: 0, heading: 0)
let pinLocation = CLLocationCoordinate2D(latitude: latitude, longitude: longitude)
let rotationCamera = MKMapCamera(lookingAtCenter: pinLocation, fromDistance: 2000, pitch: 75, heading: 180)
UIView.animate(withDuration: 10, delay: 0, options: .curveEaseInOut, animations: {
self.mapView.camera = rotationCamera
}, completion: nil)发布于 2014-01-15 08:00:40
我不使用计时器,而是在MKMapViewDelegate的mapView:regionDidChangeAnimated:方法中更改音高。
发布于 2014-01-15 15:53:04
也许可以尝试使用KVO来观察mapView.region的变化?
https://stackoverflow.com/questions/21125573
复制相似问题