I am using the new iOS 18 TabView
with TabSection
and Tab
as child views. The main deployment for my app is iPad so it is critical that this works properly.
When the iPad is landscape, I should be able to Split View and display another app alongside - so long as "Requires Full Screen" is set to NO in info.plist.
For the most part I can do this. And when I remove the TabSection
s from the TabView
the problem goes away. But I must keep the TabSection
s as my actual app has 14 Tab
s and there seems to be a limit on standalone Tabs
s. So as it stands, for just two of my views, there is some very random and strange behaviour.
In my very simple min reproducible example below, when the iPad is landscape and the sidebar is hidden (only the menu across the top is visible) I can successfully run Split View for ALL of the Tab
s in my list. Whenever the sidebar is displayed (which would be the standard landscape setup) and my "Location Brief" or "Restricted Area Brief" Tabs are selected, the app crashes. So the issue I believe is with the sidebar, as I get this error:
SwiftUI/SidebarAdaptableTabViewStyle_iOS.swift:482: Fatal error: Tried to update with invalid selection value
The sidebar also seems to be "sticky" with the highlight of the "Location Brief" in its menu too, where selecting it first and then selecting "Area Brief" changes the Content View but doesn't change the selection in the sidebar menu....
Another issue is that when in Split View with the "NOTAM" Tab active and the split is 50/50 or greater, narrowing the view to less than this will switch to "Area Brief".
I must keep Split View an option for this app, and I must have a sidebar visible for landscape operation.
I have tried to closely follow Apple's documentation and have looked at lots of forums etc. but I still get the issue. What can I try next?
Min deployment iOS 18, Simulator is running 18.2, Swift 16.2
import SwiftUI
@main
struct scrapAppApp: App {
var body: some Scene {
WindowGroup {
MenuView()
}
}
}
.
import SwiftUI
struct MenuView: View {
@AppStorage("MyAppTabViewCustomization")
private var customization: TabViewCustomization
@State private var selectedTab: Tabs?
enum Tabs: String, Hashable, CaseIterable {
case planner, plan, weather, locationbrief, areabrief, additional, notam, restrictedBrief, appSettings, settings
var customizationID: String {
rawValue
}
}
var body: some View {
TabView(selection: $selectedTab) {
TabSection("Planner") {
Tab("Plan", systemImage: "paperplane", value: Tabs.plan) {
Text("Plan")
}.customizationID(Tabs.plan.customizationID)
}.customizationID(Tabs.planner.customizationID)
TabSection("Weather") {
Tab("Location Brief", systemImage: "mappin.square", value: Tabs.locationbrief) {
Text("Location Brief") // this crashes ..........................
}.customizationID(Tabs.locationbrief.customizationID)
Tab("Area Brief", systemImage: "map", value: .areabrief) {
Text("Area Brief")
}.customizationID(Tabs.areabrief.customizationID)
}.customizationID(Tabs.weather.customizationID)
TabSection("Additional") {
Tab("NOTAM", systemImage: "text.document", value: Tabs.notam) {
Text("NOTAM")
}.customizationID(Tabs.notam.customizationID)
Tab("Restricted Area Brief", systemImage: "xmark.seal", value: .restrictedBrief) {
Text("Restricted Area Brief") // this crashes ..........................
}.customizationID(Tabs.restrictedBrief.customizationID)
}.customizationID(Tabs.additional.customizationID)
TabSection("App Settings") {
Tab("Settings", systemImage: "gear", value: Tabs.settings) {
Text("Settings")
}.customizationID(Tabs.settings.customizationID)
}.customizationID(Tabs.appSettings.customizationID)
}
.tabViewStyle(.sidebarAdaptable)
.tabViewCustomization($customization)
}
}
#Preview {
MenuView()
}
I am using the new iOS 18 TabView
with TabSection
and Tab
as child views. The main deployment for my app is iPad so it is critical that this works properly.
When the iPad is landscape, I should be able to Split View and display another app alongside - so long as "Requires Full Screen" is set to NO in info.plist.
For the most part I can do this. And when I remove the TabSection
s from the TabView
the problem goes away. But I must keep the TabSection
s as my actual app has 14 Tab
s and there seems to be a limit on standalone Tabs
s. So as it stands, for just two of my views, there is some very random and strange behaviour.
In my very simple min reproducible example below, when the iPad is landscape and the sidebar is hidden (only the menu across the top is visible) I can successfully run Split View for ALL of the Tab
s in my list. Whenever the sidebar is displayed (which would be the standard landscape setup) and my "Location Brief" or "Restricted Area Brief" Tabs are selected, the app crashes. So the issue I believe is with the sidebar, as I get this error:
SwiftUI/SidebarAdaptableTabViewStyle_iOS.swift:482: Fatal error: Tried to update with invalid selection value
The sidebar also seems to be "sticky" with the highlight of the "Location Brief" in its menu too, where selecting it first and then selecting "Area Brief" changes the Content View but doesn't change the selection in the sidebar menu....
Another issue is that when in Split View with the "NOTAM" Tab active and the split is 50/50 or greater, narrowing the view to less than this will switch to "Area Brief".
I must keep Split View an option for this app, and I must have a sidebar visible for landscape operation.
I have tried to closely follow Apple's documentation and have looked at lots of forums etc. but I still get the issue. What can I try next?
Min deployment iOS 18, Simulator is running 18.2, Swift 16.2
import SwiftUI
@main
struct scrapAppApp: App {
var body: some Scene {
WindowGroup {
MenuView()
}
}
}
.
import SwiftUI
struct MenuView: View {
@AppStorage("MyAppTabViewCustomization")
private var customization: TabViewCustomization
@State private var selectedTab: Tabs?
enum Tabs: String, Hashable, CaseIterable {
case planner, plan, weather, locationbrief, areabrief, additional, notam, restrictedBrief, appSettings, settings
var customizationID: String {
rawValue
}
}
var body: some View {
TabView(selection: $selectedTab) {
TabSection("Planner") {
Tab("Plan", systemImage: "paperplane", value: Tabs.plan) {
Text("Plan")
}.customizationID(Tabs.plan.customizationID)
}.customizationID(Tabs.planner.customizationID)
TabSection("Weather") {
Tab("Location Brief", systemImage: "mappin.square", value: Tabs.locationbrief) {
Text("Location Brief") // this crashes ..........................
}.customizationID(Tabs.locationbrief.customizationID)
Tab("Area Brief", systemImage: "map", value: .areabrief) {
Text("Area Brief")
}.customizationID(Tabs.areabrief.customizationID)
}.customizationID(Tabs.weather.customizationID)
TabSection("Additional") {
Tab("NOTAM", systemImage: "text.document", value: Tabs.notam) {
Text("NOTAM")
}.customizationID(Tabs.notam.customizationID)
Tab("Restricted Area Brief", systemImage: "xmark.seal", value: .restrictedBrief) {
Text("Restricted Area Brief") // this crashes ..........................
}.customizationID(Tabs.restrictedBrief.customizationID)
}.customizationID(Tabs.additional.customizationID)
TabSection("App Settings") {
Tab("Settings", systemImage: "gear", value: Tabs.settings) {
Text("Settings")
}.customizationID(Tabs.settings.customizationID)
}.customizationID(Tabs.appSettings.customizationID)
}
.tabViewStyle(.sidebarAdaptable)
.tabViewCustomization($customization)
}
}
#Preview {
MenuView()
}
Share
Improve this question
edited 2 days ago
HangarRash
15.1k5 gold badges19 silver badges55 bronze badges
asked 2 days ago
PW1990PW1990
4792 silver badges11 bronze badges
4
|
1 Answer
Reset to default 0I have a potential source of the error and have been able to iron out almost all of the issues by retaining only 1 TabSection
and leaving all others as a standalone Tab
.
So for anyone with the same issue, it seems that multiple TabSection
s cause this problem.
Crashes are resolved completely and when within a standalone Tab
the resizing of the Split View doesn't switch between views. This switching does however still occur with Tab
s within the TabSection
.
Tabs.
eg for.restrictedBrief
and.areabrief
. – workingdog support Ukraine Commented 2 days ago