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.
Post
Replies
Boosts
Views
Activity
Hello everybody,
Does anybody have an update on this? I am struggling with Version 12.5 (12E262) and still the crash occurs, and I still can't scroll the wheels programmatically fast.