Post

Replies

Boosts

Views

Activity

watchOS - map shows for an instant, then replaced with blue screen
I have a watchOS app that shows a map with the device's current location. This works as expected on a simulator. On a device in TestFlight, the map shows for an instant, but then the map area turns blue. When I zoom in and out, again, the correct map shows for an instant, but then the screen turns blue. I have a couple of images to illustrate the issue: I'm attaching the mapping code below: super.awake(withContext: context) if CLLocationManager.locationServicesEnabled() { locationManager.requestAlwaysAuthorization() locationManager.requestWhenInUseAuthorization() locationManager.delegate = self locationManager.desiredAccuracy = kCLLocationAccuracyBest locationManager.distanceFilter = kCLDistanceFilterNone locationManager.startUpdatingLocation() } else { print("Problem with permissions") return } let span = MKCoordinateSpan( latitudeDelta: 0.005, longitudeDelta: 0.005 ) #if targetEnvironment(simulator) let location = CLLocationCoordinate2D( latitude: simulatorLatitude, longitude: simulatorLongitude ) let region = MKCoordinateRegion(center: location, span: span) mapView.setRegion(region) mapView.addAnnotation(location, withImageNamed: "mapPinRed", centerOffset: CGPoint(x: 0, y: 0)) #else locationManager.requestLocation() #endif } override func willActivate() { // This method is called when watch view controller is about to be visible to user } override func didDeactivate() { // This method is called when watch view controller is no longer visible } func locationManager(_ manager: CLLocationManager, didChangeAuthorization status: CLAuthorizationStatus) { print(#function, "Status: ", status.rawValue) if status.rawValue == 0 { locationManager.requestAlwaysAuthorization() locationManager.requestWhenInUseAuthorization() locationManager.requestLocation() } } func locationManager(_ manager: CLLocationManager, didUpdateLocations locations: [CLLocation]) { let currentLocation = locations[0] let lat = currentLocation.coordinate.latitude let long = currentLocation.coordinate.longitude self.mapLocation = CLLocationCoordinate2DMake(lat, long) //let span = MKCoordinateSpan.init(latitudeDelta: 0.1, longitudeDelta: 0.1) let region = MKCoordinateRegion.init() self.mapView.setRegion(region) self.mapView.addAnnotation(self.mapLocation!, with: .red) } func centerMapOnLocation(location: CLLocation) { #if targetEnvironment(simulator) let region = MKCoordinateRegion(center: CLLocationCoordinate2D(latitude: simulatorLatitude, longitude: simulatorLongitude), span: MKCoordinateSpan(latitudeDelta: CLLocationDegrees(zoomValue), longitudeDelta: CLLocationDegrees(zoomValue))) DispatchQueue.main.async { self.mapView.setRegion(region) } #else let region = MKCoordinateRegion(center: CLLocationCoordinate2D(latitude: location.coordinate.latitude, longitude: location.coordinate.longitude), span: MKCoordinateSpan(latitudeDelta: CLLocationDegrees(zoomValue), longitudeDelta: CLLocationDegrees(zoomValue))) DispatchQueue.main.async { [self] in self.mapView.setRegion(region) self.mapView.addAnnotation(location.coordinate, withImageNamed: "mapPinRed", centerOffset: CGPoint(x: 0, y: 0)) } #endif } My permissions are set in Watch.extension info.plist as follows: Privacy - Location Always Usage Description Privacy - Location Always and When In Use Usage Description Privacy - Location Usage Description I  would appreciate any help.
0
0
707
Jan ’22
More help with CloudKit please
Hi, I'm trying to add CloudKit to my app. I've added a provisioning profile to the app, after enabling the required entitlements. When I run the app, I get the following message: Error Domain=SyncedDefaults Code=101010 "Tried to access unknown store xxxxxxxxx.com.bohtech.xxxxxxxx" UserInfo={NSLocalizedDescription=Tried to access unknown store I can see the container through the Apple website. I can see the Private Zone. I cannot get further than that. I've tried rebuilding the entitlement file, restarting my computer. Disabling and re-enabling the container through Xcode. Can someone out there point me to any help? Thanks in advance.
0
0
666
Nov ’22
Timer doesn't quit
I have a timer that runs ok. However, when I try to stop the timer, neither function is executed. The code is as follows: ` func viewWillDisappear(animated: Bool) { super.viewWillDisappear(animated) print(#function) menuTimer = nil menuTimer?.invalidate() } override func viewDidDisappear(_ animated: Bool) { print(#function) super.viewDidDisappear(animated) menuTimer = nil menuTimer?.invalidate() } Is this a known issue or am i doing something wrong.
Topic: UI Frameworks SubTopic: UIKit Tags:
3
0
676
Jul ’23