
输入
|
115
图
3
-
4
:选择背景模式的 “Location updates”
另外,我们还需要在项目的
Info.plist
文件中增加一个
NSLocationAlwaysUsageDesc
ription
条目
,
并在条目的值中填写程序使用用户位置信息的用途。
编辑
ViewController.swift
的代码如下:
import UIKit
import CoreLocation
class ViewController: UIViewController, CLLocationManagerDelegate {
var locationManager ...