2016-06-22 15 views
0

UIMapKitを使用したフライオーバーアニメーションで、基本的にはカメラの角度が変化してからアニメーションが始まります。私にはエラーがあり、何が間違っているのか分からない。助けてください。iOS UIView.animatewithDuration in Swift 2.2?

"ピッチは度で測定された、カメラの視野角である。カメラで0結果の 値がマップに真っ直ぐ下向き。投げされているカメラで0結果より 角度大きいですマップタイプが 衛星またはハイブリッドである場合、ピッチ値が0

にクランプされる度の指定された数によって 地平線に向かって、このプロパティの値は マップの可読性を維持するために、最大値にクランプすることができますただし、固定された最大値はありませんが、 実際の最大値はカメラの現在の高度 に依存しているためです。

さて、問題は、以下のコードによると、私はダウン、以下の0にUIMapViewピッチ値を初期化され、FUNCをオーバーライドし、それがアニメーションのための時間だとき、私は65に値を変更するので、私はカメラを期待しますアングル(ピッチ)は変わりますが、私がシミュレータを走らせると、カメラはまだマップ上でまっすぐに指されています。しかし、投球されたカメラと回転したカメラとの間の見出しが変化したため、スピンアニメーションが機能しています。

私のピッチ設定に何が問題なのか分かりません。私は何か見落としてますか?高度プロパティを追加する必要がありますか?まだそれを理解しようとする。

https://developer.apple.com/reference/mapkit/mkmapcamera

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. 
    } 

} 

答えて

0

私はそれを考え出した、iOSのシミュレータは高架道路をサポートしていませんが判明しました。だから私は実際のデバイスでそれを実行すると、私の美しい飛行機のアニメーションは、私が期待するように表示されます。

関連する問題