I created a very simple project as follows.
NavigationLink("Go To Next View", value: "TheView")
.navigationDestination(for: String.self) { val in
Text("Value = \(val)")
}
This example worked in the simple project. But when I put this into my app's project using NavigationStack, I navigated to the next view fine, but had no back button.
Post
Replies
Boosts
Views
Activity
Now it appears to be working. I hope that I can relax now.
I get the same console message. The only new method of NavigationLink that works with NavigationStack, at least for me, is the form.
NavigationLink
{ MyDestinationView(data: data) } label: {
MyRowView(data: data)
}
However, I cannot go back in the navigation stack, only forward. No back buttons. But just this morning, I replaced NavigationStack with NavigationView and I had back buttons. I reworked all of my data to fit in the new form. I think that was a good thing anyway, so I want this to work. I could be messing up. Not sure. But with others having the same issue, it could be I'm doing this okay. We shall see.
The deployment target is iOS 16.
It works on an actual Apple Watch, but not on a simulator. Knowing it works on a device is a good thing.
I am having the same issue. Not only that; the Landmarks title doesn't display in the root view on the Apple Watch. I'm using Xcode 13.4.1. Has anybody found the fix?
func placeImageModelEntity(imageAnchor: ARImageAnchor, width: Float, height: Float) {
let imageAnchorEntity = AnchorEntity(anchor: imageAnchor)
imageAnchorEntity.name = imageAnchor.name!
let screenMesh = MeshResource.generatePlane(width: width, depth: 1.33333*width, cornerRadius: 0.5)
var myMaterial = PhysicallyBasedMaterial()
if let baseResource = try? TextureResource.load(named: "MyImage") {
// Create a material parameter and assign it.
let baseColor = MaterialParameters.Texture(baseResource)
myMaterial.baseColor = PhysicallyBasedMaterial.BaseColor(texture:baseColor)
}
let imageModelEntity = ModelEntity(mesh: screenMesh, materials: [myMaterial])
let anchorWidth = imageAnchor.referenceImage.physicalSize.width
imageModelEntity.setPosition(SIMD3(x: Float(anchorWidth), y: 0, z: 0), relativeTo: imageAnchorEntity)
imageAnchorEntity.addChild(imageModelEntity)
// Add anchor to scene
arView.scene.addAnchor(imageAnchorEntity)
}
var myMaterial = PhysicallyBasedMaterial()
if let baseResource = try? TextureResource.load(named: "MyImage") {
// Create a material parameter and assign it.
let baseColor = MaterialParameters.Texture(baseResource)
myMaterial.baseColor = PhysicallyBasedMaterial.BaseColor(texture:baseColor)
}
You can create a function which returns a Bool. Here's a simple example.
let dict1 = ["Name" : "Wanda", "Age" : 32, "Gender" : "Female"] as [String : Any]
let dict2 = ["Name" : "John", "Age" : 25, "Gender" : "Male"] as [String : Any]
let dict3 = ["Name" : "Bob", "Age" : 15, "Gender" : "Male"] as [String : Any]
let dict4 = ["Name" : "Jane", "Age" : 50, "Gender" : "Female"] as [String : Any]
let dict5 = ["Name" : "Bill", "Age" : 75, "Gender" : "Female"] as [String : Any]
var dictArray = [dict5, dict3, dict1, dict4, dict2]
func dictSort(dict1: [String: Any], dict2: [String: Any]) -> Bool {
guard let i0 = dict1["Age"] as? Int,
let i1 = dict2["Age"] as? Int else {return false}
return i0 < i1
}
var sortedArray = dictArray.sorted{dictSort(dict1: $0, dict2: $1)}
I'm having the same issue, so I am very interested if anybody knows the answer to your question.
Never mind. The question turns out to be not the correct question.
Well, I fiddled with it and it works now. I'm not exactly sure what I did, but the Watch App component of my app is working. Also, I cancelled my request for tech help.
AndyJJ, yes, I have WKExtensionDelegateClassName with value $(PRODUCTMODULENAME).ExtensionDelegate in the extension's Info.plist, but I do not have the delegate adaptor in the AppDelegate. I created a project from scratch and added the watch target and it didn't generate a delegate adaptor. I'm not sure where that comes from. I am not using SwiftUI, just Swift.
My Codable struct approach worked very well. I am very happy with it.
Perhaps this is a bug. I have a code request made to Apple for help. Used one of my 'get out of jail cards' to do it. We'll see what happens.