Post

Replies

Boosts

Views

Activity

Please tell me if I am doing something wrong.
I want to determine if I am within a 10m radius of an area on my iphone's location information, but when I wait for the result and then go to the next process, the result of the inside/outside determination does not come back. Please tell me if I am doing something wrong.     func SpotArea_judgment(place: String, rad: Int, location:CLLocationCoordinate2D) -> Bool? {         var result: Bool?         let semaphore = DispatchSemaphore(value: 0)         let geocoder = CLGeocoder()         geocoder.geocodeAddressString(place) { (placemarks, error) in             let center = CLLocationCoordinate2D(                 latitude: Double(placemarks?.first?.location?.coordinate.latitude ?? 0),                 longitude: Double(placemarks?.first?.location?.coordinate.longitude ?? 0)             )             let radius: CLLocationDistance = Double(rad)             let circularRegion = CLCircularRegion(center: center, radius: radius, identifier: "identifier")             result = circularRegion.contains(location)             semaphore.signal()         }         semaphore.wait()         return result     }
1
0
340
May ’22
I would like to detect when the battery runs out or the power is turned off.
I would like to know the status of a dead battery when the application is running, but is there any way to get the status just before the battery runs out? Is there any way to get the status of the battery right before it runs out? UIDevice.current.isBatteryMonitoringEnabled = true UIDevice.current.batteryLevel but please tell us how to get the status of power off, etc. as well.
0
0
248
Apr ’22
How do I fill in CXProviderDelegate in SwiftUI?
I'm working on porting the source of an app I took from a sample to an app I created by myself by changing it to SwiftUI. I don't know how to port the following CXProviderDelegate. If I port it as is If I port it as-is, I get an error saying that the non-class type 'VideoView' cannot conform to class protocol 'CXProviderDelegate'. Please let me know how to port it. extension videoTabView: CXProviderDelegate { func providerDidReset(_ provider: CXProvider) { } func provider(_ provider: CXProvider, perform action: CXStartCallAction) { callCenter.ConfigureAudioSession() callCenter.Connecting() action.fulfill() } func provider(_ provider: CXProvider, perform action: CXAnswerCallAction) { callCenter.ConfigureAudioSession() if let peer = self.dataConnection?.peer { self.call(targetPeerId: peer) } action.fulfill() } func provider(_ provider: CXProvider, perform action: CXEndCallAction) { self.dataConnection?.close() self.mediaConnection?.close() action.fulfill() } }
3
0
847
Dec ’21
Location information using CoreLocation
Hi, I am creating an application with SwiftUI using CoreLocation. When I set the positioning system to kCLLocationAccuracyBest, the system does not appear. When I view it in GoogleMap, it sometimes shows me as if I am in a house instead of a street. Please let me know how I can improve the system. class AppDelegate: UIResponder, UIApplicationDelegate, CLLocationManagerDelegate{   var locationManager : CLLocationManager?   func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey : Any]? = nil) -> Bool{     locationManager = CLLocationManager()     locationManager!.delegate = self     locationManager!.requestAlwaysAuthorization()     if CLLocationManager.locationServicesEnabled(){       locationManager!.desiredAccuracy = kCLLocationAccuracyBest       locationManager!.distanceFilter = 10       locationManager!.allowsBackgroundLocationUpdates = true       locationManager!.pausesLocationUpdatesAutomatically = false       locationManager!.startUpdatingLocation()     }     return true   } func locationManager(_ manager: CLLocationManager, didUpdateLocations locations: [CLLocation]){     guard let newLocation = locations.last else {       return     }     let location: CLLocationCoordinate2D = CLLocationCoordinate2DMake(newLocation.coordinate.latitude, newLocation.coordinate.longitude)
2
0
463
Sep ’21
Page Switching
In SwiftUI, tapping the search button does not switch to the search page. Both SrhView () and PutView () do not switch the page.          .navigationBarTitle("Title", displayMode: .inline)         .navigationBarItems(           leading:             Button(action: {               SrhView()           }) {             Image(systemName: "magnifyingglass")         },           trailing:             Button(action: {               PutView()             }, label: {Text("PUt")}         ))
1
0
413
May ’21