0
我第一次嘗試構建watchOS應用程序開始有點粗糙。Watchkit擴展時的錯誤
當我在文件檢查器的目標成員資格框中選擇了watchkit擴展後,我的CLLocationManager委託類立即彈出了幾個錯誤,我不知道爲什麼會出現這種情況,不知道如何跟蹤這些答案問題。
因爲它適用於手錶,所以允許在iOS和watchOS的可共享代碼中集成什麼特殊限制?
不確定爲什麼特別是活動類型不可用。
import Foundation
import CoreLocation
import MapKit
import UIKit
class TrackLocationManagerDelegate: NSObject, CLLocationManagerDelegate {
lazy var locationManager: CLLocationManager = {
var locationManager = CLLocationManager()
locationManager.delegate = LocationManagerDelegate.sharedInstance
locationManager.desiredAccuracy = kCLLocationAccuracyBest
// ERROR - activityType unavailable
locationManager.activityType = CLActivityType.fitness
locationManager.distanceFilter = 10.0
return locationManager
}()
// ERROR - Use of undeclared type MKPolyline
fileprivate lazy var polyline = MKPolyline()
// ERROR - Use of Undeclared type UIViewController
func startUpdatingLocationIfAuthorized(inViewController vc: UIViewController) {
guard CLLocationManager.authorizationStatus() == .authorizedWhenInUse else {
TrackLocationManagerDelegate.sharedInstance.locationManager.requestWhenInUseAuthorization()
return
}
TrackLocationManagerDelegate.sharedInstance.locationManager.startUpdatingLocation()
}
}
謝謝,通過文檔,它回答了我所有的問題! – lifewithelliott