UIMapKit
을 사용하여 비행 애니메이션입니다. 기본적으로 애니메이션은 카메라 각도가 바뀌고 그 후에 물체를 회전합니다. 나는 오류가 있으며, 무엇이 잘못되었는지를 모른다. 도와주세요. iOS UIView.animatewithDuration in Swift 2.2?
은 " 피치 각도 측정 된 카메라의 시야각이다. 카메라 0 결과를 값 똑바로지도에서 지적. 투구 된 카메라 각도 0보다 큰 결과 지도 유형 위성 또는 하이브리드의 경우, 피치 값이 0에 클램프도 지정된 수만큼 수평선쪽으로.이 속성의 값은 지도 가독성을 유지하기위한 최대 값으로 고정 될 수있다 그래도 고정 된 최대 값은 없습니다. 실제 최대 값은 현재 카메라의 현재 고도 인 에 달려 있기 때문입니다. "
지금, 문제는, 아래의 코드에 따라, 나는 그것이 애니메이션의 시간을 때, 나는 65의 값을 변경, 그래서 카메라를 기대 아래로 아래 0, 재정 FUNC,에 UIMapView
피치 값을 초기화한다 각도 (피치)가 변경되지만 시뮬레이터에서 실행할 때 카메라는 여전히지도에서 똑바로 향하게됩니다. 그러나 투사 된 카메라와 회전 된 카메라 사이의 표제가 변경 되었기 때문에 스핀 애니메이션이 작동합니다.
내 음조 설정에 어떤 문제가 있는지 알 수 없습니다. 내가 뭐 놓친 거 없니? 고도 속성을 추가해야합니까? 아직도 그것을 알아 내려고 노력하십시오.
import UIKit
import MapKit
import CoreLocation
class ViewController: UIViewController, MKMapViewDelegate, CLLocationManagerDelegate {
let distance: CLLocationDistance = 700
let pitch: CGFloat = 65
let heading = 90.0
var camera = MKMapCamera()
let coordinate = CLLocationCoordinate2D(latitude: 40.7484405,
longitude: -73.9856644)
@IBOutlet weak var mapView: MKMapView!
override func viewDidLoad() {
super.viewDidLoad()
mapView.mapType = .SatelliteFlyover
camera = = MKMapCamera(lookingAtCenterCoordinate: coordinate,
fromDistance: distance,
pitch: 0,
heading: 0)
self.mapView.camera = camera
// Do any additional setup after loading the view, typically from a nib.
}
override func viewDidAppear(animated: Bool) {
let pitchedCamera = MKMapCamera(lookingAtCenterCoordinate: coordinate, fromDistance: distance, pitch: pitch, heading: 0)
let rotatedCamera = MKMapCamera(lookingAtCenterCoordinate: coordinate, fromDistance: distance, pitch: pitch, heading: 180)
UIView.animateWithDuration(5.0, animations: {
self.mapView.camera = pitchedCamera
}, completion: {
(Completed: Bool) -> Void in
UIView.animateWithDuration(25.0, delay: 0, options: UIViewAnimationOptions.CurveLinear, animations: {
self.mapView.camera = rotatedCamera
}, completion: nil)
})
}
override func didReceiveMemoryWarning() {
super.didReceiveMemoryWarning()
// Dispose of any resources that can be recreated.
}
}