IOS开发—App 在 IOS 8 的simulator运行时,定位卡死bug解决
2015-10-20 16:32
387 查看
今天修改的一个项目bug,在IOS 8 的simulator中运行app,就会卡死在定位的页面。原因是在 iOS 7 以及更早之前的版本,MapView 显示使用者位置不需作到 CLLocationManager,现在都要了。
在 iOS 8 上编译会出现以下 log :
Trying to start MapKit location updates without prompting for location authorization. Must call -[CLLocationManager requestWhenInUseAuthorization] or -[CLLocationManager requestAlwaysAuthorization]
first.
经搜索得到解决方法如下:
1、修改info.plist:
新增key值为NSLocationWhenInUseUsageDescription 或 NSLocationAlwaysUsageDescription(这里,我将两个都加了进去),value可以为空,也可以设置YES,不过我得问题还是不能解决,最终还是找到得了问题所在,就是info.plist中还需要包含Supported interface orientations 这个Array字段。然后运行就解决了。
2、修改代码:
在调用方法startUpdatingLocation的前面加上一句
?
3、博客原文修改方法:
?
?
上面那行是 iOS 8 以上,第二行是 iOS 7 以下,因為 kCLAuthorizationStatusAuthorized 在 iOS 8 完全不能使用。
?
在 iOS 8 上编译会出现以下 log :
Trying to start MapKit location updates without prompting for location authorization. Must call -[CLLocationManager requestWhenInUseAuthorization] or -[CLLocationManager requestAlwaysAuthorization]
first.
经搜索得到解决方法如下:
1、修改info.plist:
新增key值为NSLocationWhenInUseUsageDescription 或 NSLocationAlwaysUsageDescription(这里,我将两个都加了进去),value可以为空,也可以设置YES,不过我得问题还是不能解决,最终还是找到得了问题所在,就是info.plist中还需要包含Supported interface orientations 这个Array字段。然后运行就解决了。
2、修改代码:
在调用方法startUpdatingLocation的前面加上一句
?
?
?
相关文章推荐
- Jenkins+Gradle+pmd对Android工程源码进行静态代码分析
- Android Xfermode 实战 实现圆形、圆角图片
- [Android自定义控件] Android自定义控件
- android点亮屏幕
- iOS之图片的拉伸
- Android lint 删除无用图片文件和配置文件
- android SlidingTabLayout实现ViewPager页卡滑动效果
- Android里 listview 添加 HeaderView
- Build iOS AppRTC iOS AppRTC Deep Dive (Pt. 1)
- Android 百度地图开发(一)
- Android: 实现类似QQ、微信的表情输入键盘
- (NO.00001)iOS游戏SpeedBoy Lite成形记(三)
- (NO.00001)iOS游戏SpeedBoy Lite成形记(三)
- (NO.00001)iOS游戏SpeedBoy Lite成形记(三)
- Android 命名规范(提高代码可以读性)
- 【Android】Android Studio 使用第三方类库
- service(二) Android Studio 编写远程服务
- Jenkins+Gradle+checkstyle对Android工程源码进行静态代码分析
- 我所见过的讲"javascript中apply、call、bind"最清晰最易懂的文章
- eclipse部署项目到webapps下,如何不带contextPath来访问