无法从第4角迅速建立法律归属 [英] Could not inset legal attribution from corner 4 swift

查看:48
本文介绍了无法从第4角迅速建立法律归属的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是Xcode和移动应用程序的新手.我正在做一个应用程序以查找当前位置.我在模拟器上对其进行了测试,并在控制台中收到了此消息.无法从第4角插入法律归属".这是什么意思,我该如何解决?

I am new to Xcode and mobile app. I am doing an app to find the current location. I tested it on the simulator and got this message in the console. "Could not inset legal attribution from corner 4". What does it mean and how can I fix it?

import UIKit
import Alamofire
import AlamofireImage
import MapKit
import CoreLocation

class MapVC: UIViewController

@IBOutlet weak var mapView: MKMapView!

var locationManager = CLLocationManager()
let authorizationStatus = CLLocationManager.authorizationStatus()
let regionRadius: Double = 1000

override func viewDidLoad() {
    super.viewDidLoad()

    mapView.delegate = self
    locationManager.delegate = self
    configureLocationServices()
}

override func didReceiveMemoryWarning() {
    super.didReceiveMemoryWarning()
    // Dispose of any resources that can be recreated.
}

@IBAction func centerMapPressed(_ sender: Any) {
    if authorizationStatus == .authorizedAlways || authorizationStatus == .authorizedWhenInUse{
        centerMapOnUserLocation()
    }
}

MKMapViewDelegate:

MKMapViewDelegate:

func centerMapOnUserLocation(){
guard let coordinate = locationManager.location?.coordinate else{return}
let coordinateRegion = MKCoordinateRegionMakeWithDistance(coordinate, regionRadius*2.0, regionRadius * 2.0 )
mapView.setRegion(coordinateRegion, animated: true)

}

CLLocationManagerDelegate:

CLLocationManagerDelegate:

func configureLocationServices(){
    if authorizationStatus == .notDetermined{
        locationManager.requestAlwaysAuthorization()
    }else{
        return}
}
func locationManager(_ manager: CLLocationManager, didChangeAuthorization status: CLAuthorizationStatus) {

    centerMapOnUserLocation()
}

推荐答案

当找不到正确格式的必需信息时,会发生此问题.如果您的设备试图获取某个位置或某个数字 a 变量,而 afun 则需要该 a 变量,则该值不是设置为 a ,但调用 afun 表示发生此错误.

this issue occurs when the required information in the right form is not found. if your device i trying to get some location or some number a variable, and that a variable is required for afun.. the value is not set into a, but afun is called that this error occurs..

viewdidload 中调用单元格的坐标,而无需任何其他功能.

call your cell's coordinates in viewdidload without any other function.

这是获取单元格位置的最简单方法.1.您应该已经在infor.plist

Here is the simplest way to get your cell's position. 1. you should have updated privacies of the devices under infor.plist

在关闭标签之前,将以下几行添加到您的plist中

Add following lines into your plist before closing tag

    <key>NSLocationAlwaysAndWhenInUseUsageDescription</key>
    <string>Privacy - Location Always and When In Use Usage Description</string>
    <key>NSLocationAlwaysUsageDescription</key>
    <string>Privacy - Location Always Usage Description</string>
    <key>NSLocationWhenInUseUsageDescription</key>
    <string>Privacy - Location When In Use Usage Description</string>

之后...这是最简单的工作代码..我很乐意使用它,没有问题..

after that.. this is the simplest working code .. i'm happily using it with no issue..

import CoreLocation
import MapKit

class AddressVc: UIViewController, CLLocationManagerDelegate, MKMapViewDelegate {

    @IBOutlet weak var map: MKMapView!
    var locationManager = CLLocationManager()

这是将地图移动到所需位置的中心的代码

here is code to move map in center for the required location

    let latDelta:Double = 0.5
    let lngDelta:Double = 0.5

    let latitude:Double = 37.57554038
    let longitude:Double = -122.40068475

    let locationcoordinates = CLLocationCoordinate2D(latitude: latitude, longitude: longitude)
    let zoomSpan = MKCoordinateSpan(latitudeDelta: latDelta, longitudeDelta: lngDelta)
    let region = MKCoordinateRegion(center: locationcoordinates, span: zoomSpan)
    self.map.setRegion(region, animated: true) 

上面代码中的

..如果将设备的经纬度放置在纬度和经度上,这会将地图移动到设备的位置.

in the above code.. if you put device's lat and lng postions in latitude and lognitude that will move the map to your's devices's location.

现在如何获取设备的位置.这是您可以放入 viewDidLoad()函数中的代码.

now how to get device's location. here is the code you can put into your viewDidLoad() function.

override func viewDidLoad() {
    super.viewDidLoad()


    locationManager.delegate = self
    locationManager.desiredAccuracy = kCLLocationAccuracyBest
    locationManager.requestWhenInUseAuthorization()
    locationManager.startUpdatingLocation()

    // device latitude = (locationManager.location?.coordinate.latitude)!
    // device longitude = (locationManager.location?.coordinate.longitude)!
}

这是检测设备的纬度和经度值.您可以将它们放在上述代码中.

this is detect the device's latitude and longitude values. you can put them in above mentioned code..

这是完整的代码.

import CoreLocation
import MapKit

class AddressVc: UIViewController, CLLocationManagerDelegate, MKMapViewDelegate {

    @IBOutlet weak var map: MKMapView!
    var locationManager = CLLocationManager()


override func viewDidLoad() {
    super.viewDidLoad()


    locationManager.delegate = self
    locationManager.desiredAccuracy = kCLLocationAccuracyBest
    locationManager.requestWhenInUseAuthorization()
    locationManager.startUpdatingLocation()

    devicelatitude = (locationManager.location?.coordinate.latitude)!
    devicelongitude = (locationManager.location?.coordinate.longitude)!



    let latDelta:Double = 0.5
    let lngDelta:Double = 0.5

    let latitude:Double = devicelatitude
    let longitude:Double = devicelongitude

    let locationcoordinates = CLLocationCoordinate2D(latitude: latitude, longitude: longitude)
    let zoomSpan = MKCoordinateSpan(latitudeDelta: latDelta, longitudeDelta: lngDelta)
    let region = MKCoordinateRegion(center: locationcoordinates, span: zoomSpan)
    self.map.setRegion(region, animated: true) 
 }

我希望这会对您有所帮助..如果没有,那么会有很多其他人正面临这个问题.

I hope this will help you.. if not.. there would be many other who are facing this issue.

=========================

==========================

这篇关于无法从第4角迅速建立法律归属的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆