Post

Replies

Boosts

Views

Activity

Reply to How To Create Heatmap From Array CLCoordinate2D In A SwiftUI Map
@robnotyou quick question. Since MKMapView doesnt require a binding to region, my map shows empty blue (probably in the middle of the sea).  @State private var region = MKCoordinateRegion() MapView(region: region) .edgesIgnoringSafeArea(.all) .onAppear() {     region = ... array of CLLocationCoordinate2D }  This used to work when it was Map since i just had to go $region since the parameter required has to be binding but now it is not. How can it re-render once the region variable is set?  This is my MapView import SwiftUI import MapKit struct MapView: UIViewRepresentable {   var region: MKCoordinateRegion   var polylineCoordinates: [CLLocationCoordinate2D]?   func makeUIView(context: Context) -> MKMapView {     let mapView = MKMapView()     mapView.delegate = context.coordinator     mapView.region = region          if let polylines = polylineCoordinates {       let polyline = MKPolyline(coordinates: polylines, count: polylines.count)       mapView.addOverlay(polyline)     }           return mapView   }   func updateUIView(_ view: MKMapView, context: Context) {        }   func makeCoordinator() -> Coordinator {     Coordinator(self)   } } class Coordinator: NSObject, MKMapViewDelegate {   var parent: MapView   init(_ parent: MapView) {    self.parent = parent   }       func mapView(_ mapView: MKMapView, rendererFor overlay: MKOverlay) -> MKOverlayRenderer {     if let routePolyline = overlay as? MKPolyline {       let renderer = MKPolylineRenderer(polyline: routePolyline)       renderer.strokeColor = UIColor.systemBlue       renderer.lineWidth = 5       return renderer     }     return MKOverlayRenderer()   } }
Topic: UI Frameworks SubTopic: SwiftUI Tags:
Oct ’22
Reply to How To Open A New View From Popup Menu
Since NavigationLink does not work in a menu, some say to use binding state variables. I did manage to get it to work. But i wonder, is this the only way? It looks ugly having to have 6 state variable just for 6 menu items in the menu.
Topic: UI Frameworks SubTopic: SwiftUI Tags:
Replies
Boosts
Views
Activity
Sep ’22
Reply to Deleting Forum Posts
It has only been like 5 minute and I wanted to delete my post because I found the answer but couldn't. So no, it is not possible to do so regardless how early the post was.
Replies
Boosts
Views
Activity
Sep ’22
Reply to How To Make Optional Variables in SwiftUI View
Thank you for helping out. More or less what you provided is what i had tried The only remaining part to correct is the if let someClass. It worked when i did if let someClass = someClass Thanks
Topic: UI Frameworks SubTopic: SwiftUI Tags:
Replies
Boosts
Views
Activity
Sep ’22
Reply to How To Open A New View From Popup Menu
Thanks for the tip!
Topic: UI Frameworks SubTopic: SwiftUI Tags:
Replies
Boosts
Views
Activity
Sep ’22
Reply to URLSession dataTask Does not fetch data
Any insights will help why it works if i set .ascii instead of .utf8?
Topic: UI Frameworks SubTopic: SwiftUI Tags:
Replies
Boosts
Views
Activity
Sep ’22
Reply to URLSession dataTask Does not fetch data
I never thought about that. Thought regardless of what other encoding was set, it should be compatible with utf-8 since i didnt see any out of the ordinary character in there.
Topic: UI Frameworks SubTopic: SwiftUI Tags:
Replies
Boosts
Views
Activity
Sep ’22
Reply to Why Doesn't Date have a way to get the timezone?
Thank you both for the tips
Topic: Programming Languages SubTopic: Swift Tags:
Replies
Boosts
Views
Activity
Oct ’22
Reply to Why Main content and overflow menu button not clickable/scrollable?
I wish to understand more from the cause of this. The problem is because of .edgesIgnoringSafeArea(.all) under HStack. Once I removed this, it worked ok. But my curiosity still wonders why it works if in light mode but in dark mode the issue persists.
Topic: UI Frameworks SubTopic: SwiftUI Tags:
Replies
Boosts
Views
Activity
Oct ’22
Reply to Help Setting Google Maps
Well .. turns out the most important part for this is to run Xcode using Rosetta. Post closed.
Topic: Programming Languages SubTopic: Swift Tags:
Replies
Boosts
Views
Activity
Oct ’22
Reply to How To Create a Marker With Callout in MapKit SwiftUI
var body: some View { Map(coordinateRegion: $region, annotationItems: places) { place in MapMarker(coordinate: place.coordinate) } .edgesIgnoringSafeArea(.all) } Code is simple to show a marker. But that's it. Where does that leave callout?
Topic: UI Frameworks SubTopic: SwiftUI Tags:
Replies
Boosts
Views
Activity
Oct ’22
Reply to How To Create a Marker With Callout in MapKit SwiftUI
forum is lacking feature to delete? That's sad.
Topic: UI Frameworks SubTopic: SwiftUI Tags:
Replies
Boosts
Views
Activity
Oct ’22
Reply to How To Change/Specify Custom View In Other areas Of the View for Every Child View Change In SwiftUI
I am merely collecting information if it can be done and if yes, how. Currently I am using an EnvironmentObject to pass data settings to make the view visible or not. I am wondering if my post question is possible as this would offer more flexibility with passing views
Topic: UI Frameworks SubTopic: SwiftUI Tags:
Replies
Boosts
Views
Activity
Oct ’22
Reply to How To Create Heatmap From Array CLCoordinate2D In A SwiftUI Map
Google Maps is messy. Too many outdated code. A beginner can't tell which one should be followed. Im going back to MKMapView.
Topic: UI Frameworks SubTopic: SwiftUI Tags:
Replies
Boosts
Views
Activity
Oct ’22
Reply to How To Create Heatmap From Array CLCoordinate2D In A SwiftUI Map
@robnotyou quick question. Since MKMapView doesnt require a binding to region, my map shows empty blue (probably in the middle of the sea).  @State private var region = MKCoordinateRegion() MapView(region: region) .edgesIgnoringSafeArea(.all) .onAppear() {     region = ... array of CLLocationCoordinate2D }  This used to work when it was Map since i just had to go $region since the parameter required has to be binding but now it is not. How can it re-render once the region variable is set?  This is my MapView import SwiftUI import MapKit struct MapView: UIViewRepresentable {   var region: MKCoordinateRegion   var polylineCoordinates: [CLLocationCoordinate2D]?   func makeUIView(context: Context) -> MKMapView {     let mapView = MKMapView()     mapView.delegate = context.coordinator     mapView.region = region          if let polylines = polylineCoordinates {       let polyline = MKPolyline(coordinates: polylines, count: polylines.count)       mapView.addOverlay(polyline)     }           return mapView   }   func updateUIView(_ view: MKMapView, context: Context) {        }   func makeCoordinator() -> Coordinator {     Coordinator(self)   } } class Coordinator: NSObject, MKMapViewDelegate {   var parent: MapView   init(_ parent: MapView) {    self.parent = parent   }       func mapView(_ mapView: MKMapView, rendererFor overlay: MKOverlay) -> MKOverlayRenderer {     if let routePolyline = overlay as? MKPolyline {       let renderer = MKPolylineRenderer(polyline: routePolyline)       renderer.strokeColor = UIColor.systemBlue       renderer.lineWidth = 5       return renderer     }     return MKOverlayRenderer()   } }
Topic: UI Frameworks SubTopic: SwiftUI Tags:
Replies
Boosts
Views
Activity
Oct ’22
Reply to Region In MKMapView Not Updating In onAppear
Was following a tutorial. solution is to palce the render code in updateUIView instead of makeUIView.
Topic: UI Frameworks SubTopic: SwiftUI Tags:
Replies
Boosts
Views
Activity
Oct ’22