Post

Replies

Boosts

Views

Activity

Location Manager init called over 100 times on launch
Hi everyone. I am facing a very weird issue where the Location Manager's init method is being called over 100 times on app launch. I have added a print statement to the class init() and when I filter the results from the log I get a staggering 117 entries just in the first few seconds. Here is my setup: class LocationManager: NSObject, ObservableObject, CLLocationManagerDelegate {     private let locationManager: CLLocationManager     @Published var locationStatus: CLAuthorizationStatus?     @Published var lastLocation: CLLocation?     override init() {         //initial setup for location monitoring         locationManager = CLLocationManager()         locationManager.requestAlwaysAuthorization()                super.init()         locationManager.delegate = self         locationManager.allowsBackgroundLocationUpdates = true         locationManager.activityType = .other         locationManager.pausesLocationUpdatesAutomatically = false         locationManager.desiredAccuracy = kCLLocationAccuracyBest         locationManager.showsBackgroundLocationIndicator = false locationManager.startMonitoringSignificantLocationChanges()         startMonitoringHomeGeofence()         let monitoredRegions = locationManager.monitoredRegions         print("Monitored Regions: \(monitoredRegions.description)")         print(" | Location Monitoring setup complete(This is the line that is printed out so often)")     } } And in my apps main view I initialize the object with: @StateObject var locationManager = LocationManager() I am not sure if this is a real problem, but as this method also initializes the region monitoring which to my knowledge should only be called once on startup and the fact that I get a burst of location updates on my server every time the app launches makes this behavior look like a error in my code, or a bug on apples side. Has anyone got some ideas for me? Take care David
1
0
1.4k
Aug ’22
How can I change the background Color of a navigation view?
I'm currently creating the sidebar for my app and now I am facing the problem of how I can change the background Color of my navigation view without affecting the background of the other views. I've tried it like this: init(){ UITableView.appearance().backgroundColor = UIColor.secondarySystemBackground } That works but now all of my list backgrounds have this color, which a don't want. And if I try it like this, it doesn't change at all: ZStack{     Color.red     List{         VStack{             NavigationLink(destination: ColorMenu()){                 Label("Colors", systemImage: "square.grid.2x2.fill").accentColor(Color("Colory"))             }         }     } } So my question is if there is a way to change the background Color without affecting all the other views? Thanks in advance
4
0
4.0k
Apr ’22
is it possible to have a "floating" window in macCatalyst?
I'm currently developing an app for MacOS using macCatalyst and I now need some way to let users create some kind of sticky notes so that the window is always present. I don't want this functionality on iOS, so there should be some way to create a new window and display a view in it, or is that not possible in macCatalyst? I am using swiftUI and Xcode 12, targeting macOS BigSur. any help would be appreciated 🙃
3
0
2.6k
Jul ’21
Location Manager init called over 100 times on launch
Hi everyone. I am facing a very weird issue where the Location Manager's init method is being called over 100 times on app launch. I have added a print statement to the class init() and when I filter the results from the log I get a staggering 117 entries just in the first few seconds. Here is my setup: class LocationManager: NSObject, ObservableObject, CLLocationManagerDelegate {     private let locationManager: CLLocationManager     @Published var locationStatus: CLAuthorizationStatus?     @Published var lastLocation: CLLocation?     override init() {         //initial setup for location monitoring         locationManager = CLLocationManager()         locationManager.requestAlwaysAuthorization()                super.init()         locationManager.delegate = self         locationManager.allowsBackgroundLocationUpdates = true         locationManager.activityType = .other         locationManager.pausesLocationUpdatesAutomatically = false         locationManager.desiredAccuracy = kCLLocationAccuracyBest         locationManager.showsBackgroundLocationIndicator = false locationManager.startMonitoringSignificantLocationChanges()         startMonitoringHomeGeofence()         let monitoredRegions = locationManager.monitoredRegions         print("Monitored Regions: \(monitoredRegions.description)")         print(" | Location Monitoring setup complete(This is the line that is printed out so often)")     } } And in my apps main view I initialize the object with: @StateObject var locationManager = LocationManager() I am not sure if this is a real problem, but as this method also initializes the region monitoring which to my knowledge should only be called once on startup and the fact that I get a burst of location updates on my server every time the app launches makes this behavior look like a error in my code, or a bug on apples side. Has anyone got some ideas for me? Take care David
Replies
1
Boosts
0
Views
1.4k
Activity
Aug ’22
How can I change the background Color of a navigation view?
I'm currently creating the sidebar for my app and now I am facing the problem of how I can change the background Color of my navigation view without affecting the background of the other views. I've tried it like this: init(){ UITableView.appearance().backgroundColor = UIColor.secondarySystemBackground } That works but now all of my list backgrounds have this color, which a don't want. And if I try it like this, it doesn't change at all: ZStack{     Color.red     List{         VStack{             NavigationLink(destination: ColorMenu()){                 Label("Colors", systemImage: "square.grid.2x2.fill").accentColor(Color("Colory"))             }         }     } } So my question is if there is a way to change the background Color without affecting all the other views? Thanks in advance
Replies
4
Boosts
0
Views
4.0k
Activity
Apr ’22
is it possible to have a "floating" window in macCatalyst?
I'm currently developing an app for MacOS using macCatalyst and I now need some way to let users create some kind of sticky notes so that the window is always present. I don't want this functionality on iOS, so there should be some way to create a new window and display a view in it, or is that not possible in macCatalyst? I am using swiftUI and Xcode 12, targeting macOS BigSur. any help would be appreciated 🙃
Replies
3
Boosts
0
Views
2.6k
Activity
Jul ’21