小编iOS*_*eam的帖子

Swift 2 - 无法通过CLLocationManager获取用户位置

这是我的VC代码:

import UIKit
import MapKit
import CoreLocation

class ViewController: UIViewController, MKMapViewDelegate, CLLocationManagerDelegate {
    @IBOutlet weak var mapView: MKMapView!
    let locationManager = CLLocationManager()

    override func viewDidLoad() {
        super.viewDidLoad()

        locationManager.delegate = self
        locationManager.requestWhenInUseAuthorization()
        mapView.showsUserLocation = true
    }

    func locationManager(manager: CLLocationManager, didChangeAuthorizationStatus status: CLAuthorizationStatus) {
        mapView.showsUserLocation = (status == .AuthorizedAlways)
    }

    func locationManager(manager: CLLocationManager, didUpdateLocations locations: [CLLocation]) {
        let locValue:CLLocationCoordinate2D = manager.location!.coordinate
        print("locations = \(locValue.latitude) \(locValue.longitude)")
    }
}
Run Code Online (Sandbox Code Playgroud)

我还在plist文件中添加了NSLocationWhenInUseUsageDescription.我有CoreLocation和MapKit框架,任何想法为什么这不起作用?它不会在地图上显示用户位置,也不会打印出用户的坐标.在堆栈溢出时没有在网上找到任何东西.

cllocationmanager ios swift xcode7 swift2

3
推荐指数
1
解决办法
4657
查看次数

将一个印地语语言编号转换为阿拉伯语语言编号

在Swift中遇到过一个问题 印地语数字集整数值

这是关于我们如何将印地语翻译成英语的任何数字值.

很想知道如何将一个语言编号转换为另一个语言编号

例如:尝试将印地语语言编号转换为阿拉伯语

这是我在操场上尝试过的代码:

let string = "?"

let intParse1 = Int(string)

let numberFormat = NumberFormatter()
numberFormat.locale = Locale(identifier: "ar")

if let getOP = numberFormat.number(from: string) {
    print("output is: ", getOP)
}
Run Code Online (Sandbox Code Playgroud)

以下是仅以英文显示的输出

在此输入图像描述

我已经搜索过这个问题,但没有找到这种特定的解决方案,所以发布了一个新的问题.

注意:不寻找任何静态转换扩展或那种功能.

编辑: 我不想要这种解决方案

在Swift中将arabic String转换为英文数字

编辑2:

我想知道为什么我们必须首先将它转换为数字,然后将其转换为阿拉伯语?,意味着有必要先将它转换为英语吗?

nsnumberformatter ios swift

0
推荐指数
1
解决办法
146
查看次数