//
// ViewController.swift
// ドコロカ
//
// Created by ST01 on 2023/05/26.
//
import UIKit
import MapKit
import CoreLocation
class ViewController: UIViewController,MKMapViewDelegate,CLLocationManagerDelegate {
@IBOutlet weak var mapView: MKMapView!
var locationManager = CLLocationManager()
override func viewDidLoad() { super.viewDidLoad() mapView.delegate = self mapView.mapType = .hybridFlyover let location: CLLocationCoordinate2D = CLLocationCoordinate2DMake(37, 130) var region: MKCoordinateRegion = mapView.region region.center = location region.span.latitudeDelta = 0.5 region.span.longitudeDelta = 0.5 mapView.setRegion(region, animated: true) let pin = MKPointAnnotation() pin.coordinate = CLLocationCoordinate2DMake(location.latitude, location.longitude) pin.title = "タイトル" pin.subtitle = "どこでしょうか" mapView.addAnnotation(pin) locationManager.delegate = self if CLLocationManager.locationServicesEnabled() { locationManager.startUpdatingLocation() } if CLLocationManager.authorizationStatus() == .authorizedAlways { locationManager.allowsBackgroundLocationUpdates = true }else { locationManager.allowsBackgroundLocationUpdates = false } locationManager.distanceFilter = 10 locationManager.startUpdatingHeading() } func locationManager(_ manager: CLLocationManager, didUpdateLocations locations: [CLLocation]) { if let newLocation = locations.last { let location:CLLocationCoordinate2D = CLLocationCoordinate2DMake(newLocation.coordinate.latitude, newLocation.coordinate.longitude) print("緯度\(location.latitude)経度\(location.longitude)") } }
}
えっと、どんな状況ですか? 何かエラーメッセージとか出てますか?
スマホに繋げて実行をするのですがダウンロードされたものを開いてみると真っ暗な画面のままです!
すみません説明不足でした。
あとそんな決まりがあったんですね。知恵袋のほうは削除させていただきました。ありがとございます
韓国の東側の海上の地図が出ますね…。何も出ないなら、Storyboard の方に問題があるのでは?

あなたの回答
tips
プレビュー