swift 笔记 保持后台的办法
来源:互联网 发布:mysql字段默认time() 编辑:程序博客网 时间:2024/06/03 15:43
class ViewController: UIViewController,CLLocationManagerDelegate,GCDAsyncUdpSocketDelegate{ let locationManager = CLLocationManager() override func viewDidLoad() { super.viewDidLoad() locationManager.desiredAccuracy = kCLLocationAccuracyThreeKilometers locationManager.delegate=self locationManager.requestAlwaysAuthorization() }}
开始GPS定位之后,程序就可以在后台保持运行.
ipad mini2真机测试一晚上掉电5%
func locationManager(manager: CLLocationManager!, didUpdateLocations locations: [AnyObject]!) { var location:CLLocation = locations[locations.count-1] as CLLocation if(location.horizontalAccuracy>0){ let gps="GPS信息:\n经度:\(location.coordinate.latitude)\n纬度:\(location.coordinate.longitude)" println(gps) } }需要在info.plist文件中加入以下几条
Privacy - Location Usage Description 我们需要访问您的地理位置信息
NSLocationAlwaysUsageDescription 我们需要访问您的地理位置信息
Required background modes App registers for location updates
0 0
- swift 笔记 保持后台的办法
- swift开发笔记20 图片上传的最简单办法
- swift开发笔记21 向服务器发送中文的可靠办法
- 保持Oracle数据库的优良性能的几种办法
- java除法保持小数点后位数的两种办法
- 后台接受list的两种办法
- Swift编程规范:保持代码优美的10个方法
- 【iOS】swift 保持代码优美的10个方法
- Swift编程规范:保持代码优美的10个方法
- SERVICE后台服务进程的自启动和保持
- Android SERVICE后台服务进程的自启动和保持
- Android SERVICE后台服务进程的自启动和保持
- SERVICE后台服务进程的自启动和保持
- Android SERVICE后台服务进程的自启动和保持
- android service后台服务进程的自启动和保持
- Android SERVICE后台服务进程的自启动和保持
- Android SERVICE后台服务进程的自启动和保持
- Android SERVICE后台服务进程的自启动和保持
- android context.getCacheDir()缓存目录
- (5)存储索引
- Python刷网页(精简版)
- (6)单词和翻译入库
- TP中集成Ucenter
- swift 笔记 保持后台的办法
- Cocos2d-x 定时器的浅析
- 从头开始学java--包
- 获取android 用到的所有开发包文件
- Codeforces Round #157 (Div. 1)C(因数分解+二分+组合数)
- Unity3D学习之(接口)
- Java EE 7 在 Tomcat7.0中部署的一个问题
- error fix 4 spark application run on windows without hadoop in local model
- 对 HashMap remove 有一些元素无法清除的现象 总结(不完整版)