xcode iOS8 beta 5 上的 UIWebView 中的定位服务不起作用
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/25176750/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Location Service in UIWebView on iOS8 beta 5 not working
提问by user2082415
Yesterday we tried the developer previews iOS 8 beta 5 with Xcode 6 Beta 5 for our App. We use location services in the webview components of our hybrid app.
昨天,我们为我们的应用程序尝试了开发人员预览 iOS 8 beta 5 和 Xcode 6 Beta 5。我们在混合应用程序的 webview 组件中使用位置服务。
I recognized that geolocating via UIWebView ist not working anymore. I verified this behavior with an example from scratch loading examplefor geolocation from the w3schools.com into a UIWebView.
我意识到通过 UIWebView 进行地理定位不再起作用。我用一个从头开始将地理定位示例从 w3schools.com加载到 UIWebView的示例验证了这种行为。
With iOS 7, (Base SDK 7.1, built with XCode 5), the notification for acceptance of the location service is prompted an after that, the app shows up under Privacy--> Location Services in the iPhone settings. With iOS 8, (Base SDK 8, built with XCode 6) the prompt doesn't occur and the webview location service is not working and no entry in the settings is made.
对于 iOS 7,(Base SDK 7.1,使用 XCode 5 构建),会提示接受定位服务的通知,然后,该应用程序显示在 iPhone 设置中的隐私--> 定位服务下。使用 iOS 8(使用 XCode 6 构建的基础 SDK 8)不会出现提示,并且 webview 位置服务不工作,并且不会在设置中输入任何内容。
I know, that with iOS 8 some changes took place for the users privacy settings especially dealing with location services in background, but I didn't expect that it will break our webview-location logic where we make use of the navigator.geolocation.getCurrentPosition(showPosition) javascript function.
我知道,在 iOS 8 中,用户隐私设置发生了一些变化,尤其是在后台处理位置服务,但我没想到它会破坏我们使用 navigator.geolocation.getCurrentPosition 的 webview-location 逻辑(showPosition) javascript 函数。
Anyway I am still not clear if this is a bug in iOS 8 beta or the result of some API changes and if, what would be the right way to adopt.
无论如何,我仍然不清楚这是 iOS 8 测试版中的错误还是某些 API 更改的结果,以及如果采用的正确方法是什么。
Thanks in advance
提前致谢
回答by Joris
I had the same problem on ios 8.3.
我在 ios 8.3 上遇到了同样的问题。
I solved the problem by adding NSLocationWhenInUseUsageDescriptionIN Custom iOS Target Properties.
It is this website that helped me: http://www.touch-code-magazine.com/working-easily-location-ios8-swift-oneshotlocationmanager/
我通过在自定义 iOS 目标属性中添加NSLocationWhenInUseUsageDescription解决了这个问题。
正是这个网站帮助了我:http: //www.touch-code-magazine.com/working-easily-location-ios8-swift-oneshotlocationmanager/