Posts

Post marked as solved
2 Replies
3.3k Views
I'm playing around with the new navigation API's offered in ipadOS16/macOS13, but having some trouble working out how to combine NavigationSplitView, NavigationStack and NavigationLink together on macOS 13 (Testing on a Macbook Pro M1). The same code does work properly on ipadOS. I'm using a two-column NavigationSplitView. Within the 'detail' section I have a list of SampleModel1 instances wrapped in a NavigationStack. On the List I've applied navigationDestination's for both SampleModel1 and SampleModel2 instances. When I select a SampleModel1 instance from the list, I navigate to a detailed view that itself contains a list of SampleModel2 instances. My intention is to navigate further into the NavigationStack when clicking on one of the SampleModel2 instances but unfortunately this doesn't seem to work. The SampleModel2 instances are selectable but no navigation is happening. When I remove the NavigationSplitView completely, and only use the NavigationStack the problem does not arise, and i can successfully navigate to the SampleModel2 instances. Here's my sample code: // Sample model definitions used to trigger navigation with navigationDestination API. struct SampleModel1: Hashable, Identifiable { let id = UUID() static let samples = [SampleModel1(), SampleModel1(), SampleModel1()] } struct SampleModel2: Hashable, Identifiable { let id = UUID() static let samples = [SampleModel2(), SampleModel2(), SampleModel2()] } // The initial view loaded by the app. This will initialize the NavigationSplitView struct ContentView: View { enum NavItem { case first } var body: some View { NavigationSplitView { NavigationLink(value: NavItem.first) { Label("First", systemImage: "house") } } detail: { SampleListView() } } } // A list of SampleModel1 instances wrapped in a NavigationStack with multiple navigationDestinations struct SampleListView: View { @State var path = NavigationPath() @State var selection: SampleModel1.ID? = nil var body: some View { NavigationStack(path: $path) { List(SampleModel1.samples, selection: $selection) { model in NavigationLink("\(model.id)", value: model) } .navigationDestination(for: SampleModel1.self) { model in SampleDetailView(model: model) } .navigationDestination(for: SampleModel2.self) { model in Text("Model 2 ID \(model.id)") } } } } // A detailed view of a single SampleModel1 instance. This includes a list // of SampleModel2 instances that we would like to be able to navigate to struct SampleDetailView: View { var model: SampleModel1 var body: some View { Text("Model 1 ID \(model.id)") List (SampleModel2.samples) { model2 in NavigationLink("\(model2.id)", value: model2) } } } struct ContentView_Previews: PreviewProvider { static var previews: some View { ContentView() } } (NOTE: also created this issue on stackoverflow here) Also created a feedback assistant item: FB10876902
Posted
by thiezn.
Last updated
.
Post not yet marked as solved
5 Replies
2.2k Views
Hi,We are trying to use the MapKit JS library to present a world map with around 2000 Marker annotations. We've added our own custom glyph as well as enable cluster annotations.We take a similar approach on our iOS app and the documentation there suggests to immediately load all annotations and not try to load them based on the region view. This works great on iOS but when using the mapkit.addAnnotations(annotations) on MapKit JS it takes a really long time to initialise the annotations (+/- 5 to 10 seconds). I've removed the callout, custom glyph and cluster annotations from our marker annotation but this doesn't seem to affect the load performance at all. Does anyone have experience using MapKit JS with 2000 or more annotations and run into similar performance issues?Cheers
Posted
by thiezn.
Last updated
.
Post not yet marked as solved
0 Replies
1.4k Views
I have a class conforming to the @ObservableObject protocol and created a subclass from it with it's own variable with the @Published property wrapper to manage state.It seems that the @published property wrapper is ignored when using a subclass. Does anyone know if this is expected behaviour and if there is a workaround?I'm running iOS 13 Beta 8 and xCode Beta 6.Here is an example of what I'm seeing. When updating the TextField on ```MyTestObject``` the Text view is properly updated with the aString value. If I update the ```MyInheritedObject```TextField the anotherString value isn't updated in the Text view.import SwiftUI class MyTestObject: ObservableObject { @Published var aString: String = "" } class MyInheritedObject: MyTestObject { @Published var anotherString: String = "" } struct MyView: View { @ObservedObject var myTestObject = MyInheritedObject() @ObservedObject var myInheritedObject = MyInheritedObject() var body: some View { NavigationView { VStack(alignment: .leading) { TextField("Update aString", text: self.$myTestObject.aString) Text("Value of aString is: \(self.myTestObject.aString)") TextField("Update anotherString", text: self.$myInheritedObject.anotherString) Text("Value of anotherString is: \(self.myInheritedObject.anotherString)") } } } }
Posted
by thiezn.
Last updated
.