1

I am walking my first steps with SwiftUI as I'm thinking about migrating my existing UIKit-based iOS app. It makes extensive use of split views. Ideally, there will be something like the iOS Mail app with a master/detail view as well as an additional (leftmost) column for selecting content, account, etc.

For now, I am stuck on some basic issues such as this one: I created a short list of navigation links and a default content to be shown when the app initially opens the detail view. This works as expected when navigating back and forth in "stacked" mode, i.e. on iPhone in portrait orientation. Changing to multiple-column view, e.g. iPhone max in landscape, the primary column is stuck after a few steps. In landscape view, I have to manually hide it by clicking on the detail, and in portrait view the detail view does no longer show at all.

import SwiftUI

@main
struct MyApp: App {
    
    var body: some Scene {
        WindowGroup {
            NavigationView {
                List {
                NavigationLink(destination: destination1) {
                    Text("Hello, World 1!")
                }
                NavigationLink(destination: destination2) {
                    Text("Hello, World 2!")
                }
                .navigationTitle("Primary")
                }
                Text("This is the default content shown when the navigation view is created.")
            }
        }
    }
        
    var destination1: some View {
        Text("Destination 1 text.")
            .navigationTitle("secondary 1")
    }
    var destination2: some View {
        Text("Destination 2 text.")
            .navigationTitle("secondary 2")
    }
}
  • I think it is yet another bug. – workingdog support Ukraine Jan 17 '22 at 00:01
  • That would be a pretty massive bug and mean that the NavigationView is not working at all. A list with two items - the example couldn't be much simpler. Hopefully, there is some workaround. –  Jan 17 '22 at 08:02
  • 1
    I could not make it work without adding `.navigationViewStyle(.stack)` It seems it's either a stack or not working. I'll also be interested in a good workaround. – workingdog support Ukraine Jan 17 '22 at 08:19
  • 1
    Has anyone confirmed this on a real device? I see the primary column not disappearing on the simulator on an iPad and 13 Pro Max, but I am not seeing the lock out in portrait mode where the detail does not show at all. Has a radar been filed? – Yrb Jan 20 '22 at 14:45
  • 1
    I observed this with real devices iPhone 13 Pro Max, iPad Air and with an iPad Simulator. Just to clarify what I meant: on iPads and max-size iPhones the primary view does not cover the entire screen, so one can hide the primary view by tapping on the secondary. I assume that this should happen automatically upon selection because it would be consistent with existing apps and with what it initially does until it's "stuck". On iPhone portrait view (and all other iPhones), this must happen or one cannot navigate. Of course, I happily stand wrong on my assumptions if that solves the issue. :) –  Jan 20 '22 at 15:18
  • 1
    same here, observed this issue on a real iPhone ios15.2 and ios15.3. First in portrait mode, click on a link everthing works, then turn the phone to landscape mode, click on a link, everthing works. Then back in portrait mode links are now frozen. Tried to move the code to a separate, "ContentView", no change, tried adding tags, no change. Tried with ticking all the `Device Orientations` in the `General` target settings, no change. On macos 12.2, using xcode 13.2, targets ios 15 and macCatalyst 12. – workingdog support Ukraine Jan 21 '22 at 01:47
  • 1
    Confirmed on iPhone 11. I love the idea of SwiftUI, but I'm speechless as to how Apple hypes their most broken framework with such a peace of mind. Bugs like these, or truncated `Text` (to name one), are pure insanity. – keeshux Feb 16 '22 at 22:11

0 Answers0