IPhone : How to rotate a Direction Arrow to particular location on swift

on Sunday, April 19, 2015

my app rotate an image to particular location but it's not work and the arrow rotate to the north i want the arrow rotate to the particular location if any one know what the problem ?



class ViewController: UIViewController,CLLocationManagerDelegate{

var angle = CGFloat()
var locationManager = CLLocationManager()
var arrowImageView : UIImageView? = UIImageView()
var latitudeOfTargetedPoint = CLLocationDegrees()
var longitudeOfTargetedPoint = CLLocationDegrees()
func DegreesToRadians (value: Double) -> CGFloat {
return CGFloat(value * M_PI / 180.0)
}

func RadiansToDegrees (value: Double) -> CGFloat {
return CGFloat(value * 180.0 / M_PI)
}

override func viewDidLoad() {
super.viewDidLoad()

arrowImageView!.frame = CGRect(x: 100, y: 200, width: 100, height: 100)
arrowImageView!.image = UIImage(named: "arrow.png")
view.addSubview(arrowImageView!)

if CLLocationManager.locationServicesEnabled() {

println("CLLocationManager.locationServicesEnabled")

self.locationManager.delegate = self
self.locationManager.desiredAccuracy = kCLLocationAccuracyBest;
self.locationManager.distanceFilter = 100.0;

self.locationManager.startUpdatingLocation()
self.locationManager.startUpdatingHeading()

latitudeOfTargetedPoint = 46.948737
longitudeOfTargetedPoint = 44.990891
println("lat \(latitudeOfTargetedPoint)")
println("lon \(longitudeOfTargetedPoint)")
}

}

0 comments:

Post a Comment