Showing Recent Messages
The operation couldn’t be completed. Unable to log in with account 'sinxxxxxxxx@icloud.com'. The login details for account 'sinxxxxxxxx@icloud.com' were rejected.
Why can I run program??
please teach me
Post
Replies
Boosts
Views
Activity
import UIKit
import MapKit
import CoreLocation
class ViewController: UIViewController, CLLocationManagerDelegate,UIGestureRecognizerDelegate,SearchLocationDelegate {
/// ロケーションマネージャ
var locationManager: CLLocationManager = {
// インスタンスを初期化
var locationManager = CLLocationManager()
// 取得精度の設定(1km以内の精度)
locationManager.desiredAccuracy = kCLLocationAccuracyKilometer
// 位置情報取得間隔(5m移動したら位置情報取得)
locationManager.distanceFilter = 5
return locationManager
}()
var addressString = ""
var postalCode = ""
@IBOutlet var longPress: UILongPressGestureRecognizer!
@IBOutlet weak var setButton: UIButton!
@IBOutlet weak var addressLabel: UILabel!
@IBOutlet weak var idokeiLabel: UILabel!
@IBOutlet weak var mapView: MKMapView!
override func viewDidLoad() {
super.viewDidLoad()
_ = mapView.userLocation.coordinate
locationManager.requestAlwaysAuthorization()
locationManager.requestWhenInUseAuthorization()
}
override func viewWillAppear(_ animated: Bool) {
super.viewWillAppear(animated)
}
/// アラートを表示する
func showAlert() {
let alertTitle = "位置情報取得が許可されていません。"
let alertMessage = "設定アプリの「プライバシー > 位置情報サービス」から変更してください。"
let alert: UIAlertController = UIAlertController(
title: alertTitle,
message: alertMessage,
preferredStyle: UIAlertController.Style.alert
)
// OKボタン
let defaultAction: UIAlertAction = UIAlertAction(
title: "OK",
style: UIAlertAction.Style.default,
handler: nil
)
// UIAlertController に Action を追加
alert.addAction(defaultAction)
// Alertを表示
present(alert, animated: true, completion: nil)
}
@IBAction func longPressedTap(_ sender: UILongPressGestureRecognizer) {
if sender.state == .began {
}else if sender.state == .ended {
//view内のタップ位置をtapPointにする
let tapPoint = sender.location(in: view)
let center = mapView.convert(tapPoint, toCoordinateFrom: mapView)
let lat = center.latitude
let log = center.longitude
// ピンの生成
let annotation = MKPointAnnotation()
// 緯度経度を指定
annotation.coordinate = CLLocationCoordinate2DMake(lat, log)
mapView.addAnnotation(annotation)
UINotificationFeedbackGenerator().notificationOccurred(.success)
UIImpactFeedbackGenerator(style: .heavy).impactOccurred()
}
}
//逆ジオコーディング(緯度経度から住所を取得)
func convert(lat:CLLocationDegrees,log:CLLocationDegrees){
let geocoder = CLGeocoder()
let location = CLLocation(latitude:lat,longitude: log)
geocoder.reverseGeocodeLocation(location) { [self] placeMark, error in
if let placeMark = placeMark {
if let pm = placeMark.first {
if pm.administrativeArea != nil ||
pm.locality != nil {
self.addressString = pm.postalCode! + pm.administrativeArea! + pm.locality! + pm.name!
} else {
self.addressString = pm.name!
}
self.addressLabel.text = self.addressString
self.idokeiLabel.text = "緯度:" + String(lat) + "経度:" + String(log)
// ピンの生成
let annotation = MKPointAnnotation()
// 緯度経度を指定
annotation.coordinate = CLLocationCoordinate2DMake(lat, log)
//mapViewにピンを追加
mapView.addAnnotation(annotation)
}
}
}
}
@IBAction func goNext(_ sender: Any) {
performSegue(withIdentifier: "next", sender: nil)
}
override func prepare(for segue: UIStoryboardSegue, sender: Any?) {
if segue.identifier == "next" {
let nextVC = segue.destination as! NextViewController
nextVC.delegate = self
}
}
func search(ido: String, keido: String) {
if ido.isEmpty != true && keido.isEmpty
!= true {
let idoString = ido
let keidoString = keido
let coodinate = CLLocationCoordinate2DMake(Double(idoString)!, Double(keidoString)!)
//表示範囲設定
let span = MKCoordinateSpan(latitudeDelta: 0.01, longitudeDelta: 0.01)
//領域設定
let region = MKCoordinateRegion(center: coodinate, span: span)
//領域をmapViewに反映
mapView.setRegion(region, animated: true)
//経度、緯度を住所変換
convert(lat: Double(idoString)!, log: Double(keidoString)!)
} else {
addressLabel.text = "表示できません"
}
}
@IBAction func presentLocation(_ sender: Any) {
}
/// ロケーションマネージャのセットアップ
func setupLocationManager() {
locationManager = CLLocationManager()
locationManager.requestWhenInUseAuthorization()
// マネージャの設定
let status = CLLocationManager().authorizationStatus
// ステータスごとの処理
if status == .authorizedWhenInUse {
locationManager.delegate = self
locationManager.startUpdatingLocation()
}
}
func locationManagerDidChangeAuthorization(_ manager: CLLocationManager) {
// アプリの現在の認証ステータス
let status = manager.authorizationStatus
switch status {
case .authorizedAlways, .authorizedWhenInUse:
// 位置情報取得を開始
manager.startUpdatingLocation()
case .notDetermined:
// ユーザーに許可をリクエスト
manager.requestWhenInUseAuthorization()
case .denied:
break
case .restricted:
break
default:
break
}
func locationManager(_ manager: CLLocationManager, didUpdateLocations locations: [CLLocation]) {
guard let gps = manager.location?.coordinate else {
print("error")
return
}
// 位置情報取得を停止
manager.stopUpdatingLocation()
//経度と緯度を出力する
let lat = gps.latitude
let lng = gps.longitude
print("経度:(String(describing: lat)), 緯度:(String(describing: lng))")
}
}
}
色々試してみた結果
緯度経度と郵便番号を入力して位置情報は表示されるのですが、
現在位置だけ取得出来ずに困っています。
How to set the frame for DataScannerViewController? The default scans the whole camera and I need to specify the frame
I'm using the Vision framework, but I want to get only the displayed numbers, but I don't know how to do it, so please let me know.
Sandbox: rsync.samba(7767) deny(1) file-read-data /Users/***********/Library/Developer/Xcode/DerivedData/PostalMapApp-gkhrsemmhkdxtdajrijrbopefuez/Build/Products/Debug-iphonesimulator/XCFrameworkIntermediates/GoogleUserMessagingPlatform/UserMessagingPlatform.framework/Headers
User Script Sandboxing をNoにしましたが、他のエラーが発生してしまった。
誰か解決方法を教えてください。