mapView의 속성은 direction
이며 설정할 수 있습니다. 이 속성의 값을 변경하면 맵보기가 즉시 업데이트됩니다. 변경 사항을 애니메이션으로 적용하려면 -setDirection:animated:
메서드를 대신 사용하십시오. 또는 다음과 같은 방법을 사용할 수 있습니다 방향
진북을 기준으로도 단위로 측정 된지도의 새로운 방향
func setCenter(_ centerCoordinate: CLLocationCoordinate2D, zoomLevel: Double, direction: CLLocationDirection, animated: Bool)
.
CLLocationManager에서 startUpdatingHeading 메서드를 사용하여 북쪽에서 오프셋을 계산하여 주기적으로 호출 할 수 있습니다. 필요한 경우 완성 처리기가있는이 메서드의 다른 버전이 있습니다.
** 수정 **
당신은 전화가 지향하는 방향을 추출하기 위해 다음과 같은 코드를 사용할 수 있습니다. 이 장치는 여기 (실제로는 실제 장치에서) 콘솔에 인쇄되지만 숫자 (도)를 입력하고 코드에서 장치가 얼마나 북쪽을 가리키고 있는지 확인할 수 있습니다.
import UIKit
import CoreLocation
class ViewController: UIViewController, CLLocationManagerDelegate {
var locationManager:CLLocationManager!
override func viewDidLoad() {
super.viewDidLoad()
locationManager = CLLocationManager()
locationManager.delegate = self
locationManager.startUpdatingHeading()
}
func locationManager(_ manager: CLLocationManager, didUpdateHeading heading: CLHeading) {
print(heading.magneticHeading)
}
}
저는 지금 치과 의사에게 연락하지만 1 시간 정도 후에 다시 확인합니다.
무엇이 회전할까요? – Starlord
지도 자체이므로 사용자 위치와 관련된지도상의 점이 예를 들어 북쪽 방향 인 경우지도가 회전하여 사용자/전화가 어떤 방향을 향하고 있는지 항상 실제로 가리키고 있습니다. – Dan