I’m new to Swift still and could use a little help. On the iPhone simulator my app displays how I would expect, but on the iPad everything but the tabview is located inside the sidebar. Like so:
I’d like the view to be displayed on the center of the screen with no sidebar.
Here’s my TabView:
import SwiftUI
struct MainView: View {
@StateObject var networkViewModel = NetworkController.shared
var body: some View {
if let token = NetworkController.shared.token {
TabView {
NavigationView {
ContentView()
}
.tabItem {
Label("Home", systemImage: "house.fill")
}
NavigationView {
CalendarView()
}
.tabItem {
Label("Calendar", systemImage: "calendar")
}
}
} else {
LoginView()
}
}
}
Here’s what is displaying in the screenshot above:
import SwiftUI
struct ContentView: View {
@StateObject var networkViewModel = NetworkController.shared
@State var residentController = ResidentController()
var body: some View {
NavigationStack() {
VStack{
Image("BuildingBeginnings")
.scaledToFit()
Spacer()
NavigationLink("Residents") {
ResidentView()
}
.font(.largeTitle).padding()
NavigationLink(destination: CalendarView(), label: {Text("Calendar").font(.largeTitle).padding()})
NavigationLink(destination: OrderTableView(), label: {Text("Orders").font(.largeTitle).padding()})
NavigationLink(destination: AdminView(), label: {Text("Admin").font(.largeTitle).padding()})
Spacer()
VStack(alignment: .trailing) {
Button {
networkViewModel.logout()
} label: {
Text("Sign out")
}
}
}
}
.environment(residentController)
}
}