Post

Replies

Boosts

Views

Activity

Reply to Keyboard Done Button Failing to Appear About 60% of Time
After considerable review of the Done button operation, I noticed that I could get the button to reappear by selecting another tab and then returning to the expense entry tab. I added some breakpoints and noticed that some of the state parameters were not getting reset upon saving the data. Finally, I moved the state parameter reset logic outside the getLocation closure and this appears to have fixed the state parameters for the next entry and the Done button. The weird Done button behavior is no longer occurring! func saveButton() { if moneyD == 0.0 { zeroEntry = true } else { withAnimation { // get coordinates and address getLocation { addr in self.addr = addr // address if let city = addr.locality { entryLocCity = city } if let state = addr.administrativeArea { entryLocState = state } if let countryL = addr.countryL { entryLocCountryL = countryL } if let countryS = addr.countryS { entryLocCountryS = countryS } guard let moneyD else { return } let moneyH = categories.saveCategoryTotal(entryCat: self.entryCat, rate: rate, moneyD: moneyD) modelContext.insert(TravelEntries( id: UUID(), entryDate: entryDT, ... entryLocCity: entryLocCity, entryLocState: entryLocState, entryLocCountryS: entryLocCountryS, entryLocCountryL: entryLocCountryL )) dtTotals.addToDailyTotal(gotDate: entryDT, gotTotal: moneyH) } // reset parameters for next entry self.entryDT = Date() self.entryCat = 0 self.entryPT = 0 self.entryDsc = "" self.moneyD = nil } }
Oct ’24
Reply to Implementing Map Span in iOS 17
Searching around the web I found a site showing how to initialize the map view with Map(initialPosition: .region(MKCoordinateRegion(center: span())) struct DetailPortView: View { var item: TravelEntries @Binding var mapType: Int var coordinate: CLLocationCoordinate2D { CLLocationCoordinate2D( latitude: item.entryLat, longitude: item.entryLong ) } var selectedMapStyle: MapStyle { return switch(mapType) { case 0: .standard(elevation: .realistic) case 1: .hybrid(elevation: .realistic) case 2: .imagery(elevation: .realistic) default: .standard(elevation: .realistic) } } var body: some View { VStack { Map(initialPosition: .region(MKCoordinateRegion(center: coordinate, span: (MKCoordinateSpan(latitudeDelta: 0.005, longitudeDelta: 0.005))))) { Marker("\(item.entryCatName ?? "") purchase", coordinate: coordinate) .tint(.red) } .mapStyle(selectedMapStyle) ShowMapPicker(item: item, mapType: $mapType) ShowDetails(item: item) } } }
Oct ’23
Reply to Implementing Map Span in iOS 17
I have discovered that if I add a .safeAreaInset containing a button I can then add a camera region with latitudeMeters / longitudeMeters (span): .safeAreaInset(edge: .bottom) { Button { camera = .region(MKCoordinateRegion(center: coordinate, latitudinalMeters: 750, longitudinalMeters: 750)) } label: { Text("Button") } But I don't want the user to have to hit another button for the span to get set properly. Any ideas on how to do that?
Oct ’23