0

This is on iPadOS 15.4. I'm using Xcode 13.3.1. I'm using SwiftUI. I have two files:

iPadNavigationViewTestApp.swift

@main
struct iPadNavigationViewTestApp: App {
    var body: some Scene {
        WindowGroup {
            NavigationView {
                List {
                    NavigationLink(destination: ContentView()) {
                        Text("Content View 1")
                    }
                    
                    NavigationLink(destination: AnotherContentView()) {
                        Text("Content View 2")
                    }
                    
                    NavigationLink(destination: YetAnotherContentView()) {
                        Text("Content View 3")
                    }
                }
                .listStyle(.sidebar)
                .navigationTitle("This is a test")
                
                ContentView()
            }
        }
    }
}

ContentView.swift

struct ContentView: View {
    var body: some View {
        Text("Hello, world!")
            .padding()
            .navigationTitle("ContentView")
    }
}

struct AnotherContentView: View {
    var body: some View {
        Text("Hello, world!")
            .padding()
            .navigationTitle("AnotherContentView")
    }
}

struct YetAnotherContentView: View {
    var body: some View {
        Text("Hello, world!")
            .padding()
            .navigationTitle("YetAnotherContentView")
    }
}

In the multitasking interface of iPad, the title of the view was not shown correctly:

iPad multitasking not showing title correctly

In the simulator I switched to the second view using the sidebar, and the detail view's navigation title changed to "AnotherContentView". Yet the view title on multitasking is still "ContentView". How do I let it show the correct title? Is this a bug of SwiftUI?

Skk
  • 126
  • 1
  • 8
  • Since technically `ContentView` is the 3rd panel once you click I would say it is expected. If you run your app on Catalyst you should be able to see all 3. Try leaving the `ContentView` without a title then the Second panel/ Navigation ling should take precedence. – lorem ipsum Apr 17 '22 at 13:14
  • You can also make the `ContentView` conditional `if` the navigation link selection is nil show the `ContentView` `else` don't show it. – lorem ipsum Apr 17 '22 at 13:20
  • Huh, that might explain why when I click twice the correct title shows. – Skk Apr 17 '22 at 22:04
  • Update: I tried the above and now the multitasking interface does not show the title at all – Skk Apr 17 '22 at 22:31

0 Answers0