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.
Post
Replies
Boosts
Views
Activity
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.
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
Thanks for the tip!
Any insights will help why it works if i set .ascii instead of .utf8?
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.
Thank you both for the tips
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.
Well .. turns out the most important part for this is to run Xcode using Rosetta. Post closed.
forum is lacking feature to delete? That's sad.
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?
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
Google Maps is messy. Too many outdated code. A beginner can't tell which one should be followed. Im going back to MKMapView.
@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()
}
}
Was following a tutorial. solution is to palce the render code in updateUIView instead of makeUIView.