Post

Replies

Boosts

Views

Activity

Reply to SwiftUI app crashes with NSInternalInconsistencyException
I did some online search and found a work around, posting here my findings for future reference in case someone finds this useful. Based on Paul's forum reply (https://www.hackingwithswift.com/forums/swiftui/how-do-i-append-a-new-page-into-tabview-pagetabviewstyle/2583/3449) and the associated SO question (https://stackoverflow.com/questions/63499707/tabview-with-pagetabviewstyle-does-not-update-its-content-when-state-var-cha/63500070#63500070), it seems that by marking the TabView with a new id forces a refresh without a crash. ...             TabView(selection: $selectionIndex) {                 ForEach(imageProvider.images, id: \.self) { uiImage in                     Image(uiImage: uiImage)                         .resizable()                         .aspectRatio(nil, contentMode: .fit)                         .tag(tag(for: uiImage))                 }             }             .tabViewStyle(.page)             .indexViewStyle(.page(backgroundDisplayMode: .always))             .id(imageProvider.images.count) // <--- this fixed the crash ... The reload animation is not perfect, but at least I can live with it for the time being.
Nov ’21