Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Swiftui [BUG] NavigationView and List not showing on iPad simulator only

Blank page on all kinds of iPad simulator

Go to Apple developer website to download tutorials project below:

https://developer.apple.com/tutorials/swiftui/building-lists-and-navigation

Run this on any iPad simulator, you will just get a blank page, but the code works fine on simulator of Mac/iPhone and my real iPhone device.

This is definitely a bug, and I've reported to Apple, I am posting here just want ppl like me who said this issue, pls don't waste your time on reset simulator, checking your code, restart your laptop, wait until apple to fix this.

Screenshot

enter image description here

Sample code from Apple SwiftUI tutorials project:

import SwiftUI

struct LandmarkList: View {
    var body: some View {
        NavigationView {
            List(landmarkData) { landmark in
                NavigationLink(destination: LandmarkDetail(landmark: landmark)) {
                    LandmarkRow(landmark: landmark)
                }
            }
            .navigationBarTitle(Text("Landmarks"))
        }
    }
}

struct LandmarkList_Previews: PreviewProvider {
    static var previews: some View {
        ForEach(["iPhone SE", "iPhone XS Max"], id: \.self) { deviceName in
            LandmarkList()
                .previewDevice(PreviewDevice(rawValue: deviceName))
                .previewDisplayName(deviceName)
        }
    }
}
like image 938
Sky Avatar asked Dec 14 '19 20:12

Sky


1 Answers

It's actually working just fine. By default, on iPad, the navigationStyle of a NavigationView means that you are seeing the detail view with a collapsed master view. Try rotating device or simulator and you will then see your master list. Selecting an item will push that onto the detail view. Or, swipe right from the left edge and your list will appear.

Don't like this behavior? You can set your navigation view's navigationStyle to StackNavigationViewStyle(). It will only show a single view on top at any given time.

I can't currently find an option to always show the master view as that is currently how my app is configured using a UISplitViewController. It is likely a temporary situation.

like image 88
Procrastin8 Avatar answered Oct 14 '22 12:10

Procrastin8