14.2 C
Canberra
Saturday, February 22, 2025

ios – SplitView is crashing iPad when particular Tab is chosen and Sidebar is seen


I’ve spent the final a number of days making an attempt completely different fixes and searching for solutions to this, frustratingly to no avail.

I’m utilizing the brand new iOS 18 TabView with TabSection and Tab as baby views. The primary deployment for my app is iPad so it’s vital that this works correctly.

When the iPad is panorama, I ought to be capable of Cut up View and show one other app alongside – as long as “Requires Full Display screen” is ready to NO in data.plist.

For probably the most half I can do that…And once I take away the TabSections from the TabView the issue goes away. However I need to hold the TabSections as my precise app has 14 Tabs and there appears to be a restrict on standalone Tabss. In order it stands, for simply two of my views, there’s some very random and unusual behaviour.

In my quite simple min reproducible instance beneath, when the iPad is panorama and the sidebar is hidden (solely the menu throughout the highest is seen) I can efficiently run Cut up View for ALL of the Tabs in my checklist. Every time the sidebar is displayed (which might be the usual panorama setup) and my “Location Transient” or “Restricted Space Transient” Tabs are chosen, the app crashes. So the difficulty I consider is with the sidebar, as I get this error:

SwiftUI/SidebarAdaptableTabViewStyle_iOS.swift:482: Deadly error: Tried to replace with invalid choice worth

The sidebar additionally appears to be “sticky” with the spotlight of the “Location Transient” in its menu too, the place choosing it first after which choosing “Space Transient” adjustments the Content material View however does not change the choice within the sidebar menu….

One other concern is that when in Cut up View with the “NOTAM” Tab energetic and the cut up is 50/50 or better, narrowing the view to lower than it will change to “Space Transient”…

I’m clearly doing one thing improper or have left one thing essential out.

I need to hold Cut up View an choice for this app, and I will need to have a sidebar seen for panorama operation.

I’ve tried to intently comply with Apple’s documentation and have checked out plenty of boards and so on. however I nonetheless get the difficulty.

Any assist can be significantly appreciated with this as I’m completely caught right here and it’s tremendous irritating.

Min deployment iOS 18, Simulator is working 18.2, Swift 16.2

import SwiftUI

@foremost
struct scrapAppApp: App {
    var physique: some Scene {
        WindowGroup {
            MenuView()
        }
    }
}

.

import SwiftUI

struct MenuView: View {
    
    @AppStorage("MyAppTabViewCustomization")
    non-public var customization: TabViewCustomization
    
    @State non-public var selectedTab: Tabs?
    
    enum Tabs: String, Hashable, CaseIterable {
        case planner, plan, climate, locationbrief, areabrief, extra, notam, restrictedBrief, appSettings, settings
        
        var customizationID: String {
            rawValue
        }
    }
    
    var physique: some View {
        TabView(choice: $selectedTab) {
            TabSection("Planner") {
                
                Tab("Plan", systemImage: "paperplane", worth: Tabs.plan) {
                    Textual content("Plan")
                }.customizationID(Tabs.plan.customizationID)
            }.customizationID(Tabs.planner.customizationID)
            
            
            TabSection("Climate") {
                
                Tab("Location Transient", systemImage: "mappin.sq.", worth: Tabs.locationbrief) {
                    Textual content("Location Transient") // this crashes ..........................
                }.customizationID(Tabs.locationbrief.customizationID)
                
                Tab("Space Transient", systemImage: "map", worth: .areabrief) {
                    Textual content("Space Transient")
                }.customizationID(Tabs.areabrief.customizationID)

            }.customizationID(Tabs.climate.customizationID)
            
            
            TabSection("Extra") {
                
                Tab("NOTAM", systemImage: "textual content.doc", worth: Tabs.notam) {
                    Textual content("NOTAM")
                }.customizationID(Tabs.notam.customizationID)
                
                Tab("Restricted Space Transient", systemImage: "xmark.seal", worth: .restrictedBrief) {
                    Textual content("Restricted Space Transient") // this crashes ..........................
                }.customizationID(Tabs.restrictedBrief.customizationID)
                
            }.customizationID(Tabs.extra.customizationID)
            
            
            TabSection("App Settings") {
                
                Tab("Settings", systemImage: "gear", worth: Tabs.settings) {
                    Textual content("Settings")
                }.customizationID(Tabs.settings.customizationID)
                
            }.customizationID(Tabs.appSettings.customizationID)
        }
        .tabViewStyle(.sidebarAdaptable)
        .tabViewCustomization($customization)
    }
}

#Preview {
    MenuView()
}

Related Articles

LEAVE A REPLY

Please enter your comment!
Please enter your name here

[td_block_social_counter facebook="tagdiv" twitter="tagdivofficial" youtube="tagdiv" style="style8 td-social-boxed td-social-font-icons" tdc_css="eyJhbGwiOnsibWFyZ2luLWJvdHRvbSI6IjM4IiwiZGlzcGxheSI6IiJ9LCJwb3J0cmFpdCI6eyJtYXJnaW4tYm90dG9tIjoiMzAiLCJkaXNwbGF5IjoiIn0sInBvcnRyYWl0X21heF93aWR0aCI6MTAxOCwicG9ydHJhaXRfbWluX3dpZHRoIjo3Njh9" custom_title="Stay Connected" block_template_id="td_block_template_8" f_header_font_family="712" f_header_font_transform="uppercase" f_header_font_weight="500" f_header_font_size="17" border_color="#dd3333"]
- Advertisement -spot_img

Latest Articles