Learn Courses My Dashboard

iPad displays almost blank screen instead of list

My app works fine on the iPhone, but when I start it on the iPad, I get this:

If I click ‘Bills & Periodicals’, I get the list I expected. From then on, it works fine, except when I click on the ‘Settings’ tab on the bottom, I get this:


Again, if I click on ‘Settings’ on the top, the Settings screen appears. After that, both screens work as expected.

Here’s my ContentView:

import SwiftUI

struct ContentView: View
{
  @StateObject var periodicals = Periodicals()

  var body: some View
  {
    TabView
    {
      ItemsView()
        .tabItem
        { Label("List", systemImage: "list.dash") }
        .tag("items")

      SettingsView()
        .tabItem
        { Label("Settings", systemImage: "slider.vertical.3") }
        .tag("settings")
    }
    .environmentObject(periodicals)
  }
}

None of this happens on the iPhone. On that, it works as expected: The ItemsView screen shows when the app starts and the SettingView shows when I click the tab.

Is there something about the iPad that causes this?

Is anything in a navigation view?

If so add this modifier navigationViewStyle(StackNavigationViewStyle())

Wow! That fixed a bunch of problems. Thank you.