利用相机、运动和定位功能丰富应用以及在 Spotlight 中展示应用内容
1. 完成艺术应用登录屏幕
要完成登录屏幕,需确保满足 CoreLocation 示例的正确先决条件。具体操作步骤如下:
1. 确保隐私密钥存在 :首先要保证应用的 Info.plist 中存在正确的隐私密钥。
2. 编写查询用户位置并更新 UI 的代码 :
- 在 ViewController 类中添加以下两个属性:
swift @IBOutlet var nearbyArtLabel: UILabel! let locationManager: CLLocationManager = CLLocationManager()
这里, nearbyArtLabel 用于向用户显示信息, locationManager 用于查询用户位置。
- 在 ViewController 中添加 setupLocationUpdates 方法:
swift func setupLocationUpdates() { locationManager.delegate = self let authStatus = CLLocationManager.authorizationStatus() switch authStatus { case .notDetermined: locationManager.requestWhenInUseAuthorization() case .aut
超级会员免费看
订阅专栏 解锁全文
2302

被折叠的 条评论
为什么被折叠?



