[英]iOS Webkit not working on device, but works on simulator at swift
[英]xcode 8 swift 3 latlong working on simulator but not in device
我有这段代码来获取位置latlong
import Foundation
import CoreLocation
class Utilities{
static let locationManager = CLLocationManager()
static func InitLocator(Delegate:CLLocationManagerDelegate){
locationManager.desiredAccuracy = kCLLocationAccuracyBest
locationManager.delegate = Delegate
locationManager.requestAlwaysAuthorization()
locationManager.distanceFilter = kCLDistanceFilterNone
locationManager.startUpdatingLocation()
}
static func GetLatLong() -> [String]{
var arrLatLong:[String] = []
if let latitude = locationManager.location?.coordinate.latitude{
arrLatLong.append(String(latitude))
}else{
arrLatLong.append("")
}
if let longitude = locationManager.location?.coordinate.longitude{
arrLatLong.append(String(longitude))
}else{
arrLatLong.append("")
}
return arrLatLong
}
}
当我在模拟器中测试或运行它时,此方法有效,但是当我在实际设备中对其进行测试时,它为我提供了空白值。 我使用Xcode 8 swift,设备是Iphone 6s IOS 9.3.1
试试看
添加locationManager.requestWhenInUseAuthorization()
和info.plist
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.