-
Notifications
You must be signed in to change notification settings - Fork 1
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Hello. We would really appreciate it if you let us know if you found a solution or a workaround to this issue. #3
Comments
@hugo53 no solution yet for me but I have to figure something out. I am creating an app and will be maintaining it for the far future so I hope someday this issue will be resolved. If I ever find something I will report it here and in the Stackoverflow question. I've reported this as a bug to Apple. Please let us know if you find a fully working workaround or a fix. Thank you. |
Im leaning toward a limited sized VStack. It's the only way I can seem to get rid of jittering on my variable sized views. The only downside is the initial load time and hang right when you begin scrolling, but after that it's buttery smooth. I'm trying to find a solution to this. I will also probably need some kind of pagination that adds more views once I scroll near the bottom. |
@djmango Thank you for sharing the great information. Could you please share more how you did with pagination solution? |
@hugo53 here's an example of a basic implementation, i might make it an actual pagination rather than a boolean collapsed vs all view in the future but this works solid for now. struct ExampleScrollView: View {
@State private var showAll = false
private var displayedItems: [Item] {
if showAll {
return GenericViewModel.shared.items
} else {
let suffix = GenericViewModel.shared.items.suffix(10)
return Array(suffix)
}
}
var body: some View {
ScrollViewWithStickyHeader(
header: {
Rectangle().hidden()
Button(
action: { showAll.toggle() }
) {
Text(showAll ? "Show last 10" : "Show all")
}
.visible(if: GenericViewModel.shared.items.count > 10)
.keyboardShortcut("i", modifiers: [.command, .shift])
},
headerHeight: 200,
headerMinHeight: 0,
onScroll: handleOffset
) {
VStack(alignment: .trailing, spacing: 5) {
ForEach(displayedItems) { item in
ItemView(item: item)
.id(item.id)
}
}
}
.scrollContentBackground(.hidden)
.scrollIndicators(.never)
.defaultScrollAnchor(.bottom)
}
} |
I can't belive I am asking the same question 2 years later but its causing a big problem within my application on iOS 16.
If anyone else in the future comes up with a solution to the issue Chrys described below, please kindly respond here or on the Stackoverflow question.
Thank you.
https://www.youtube.com/watch?v=z2pybl5yYqk
https://stackoverflow.com/questions/66523786/swiftui-putting-a-lazyvstack-or-lazyhstack-in-a-scrollview-causes-stuttering-a
The text was updated successfully, but these errors were encountered: