I have the following code:
struct ContentView: View {
var columnGridItems = [
GridItem(.flexible()),
GridItem(.flexible()),
GridItem(.flexible()),
GridItem(.flexible())
]
@State var items = [Int]()
var body: some View {
GeometryReader { geo in
let w = geo.size.width / 4
ScrollView {
LazyVGrid(columns: columnGridItems, alignment: .center, spacing: 2) {
ForEach(items, id:\.self) { i in
CellViewS(i: i)
.frame(width:w, height:w)
}
}
}
.background(.red)
.onAppear {
for i in 0..<100 {
items.append(i)
}
}
}
}
}
struct CellView:View {
let i:Int
var body: some View {
ZStack {
RoundedRectangle(cornerRadius: 10)
.fill(.black)
.padding(5)
Text("SOME TEXT")
.foregroundColor(.white)
}
}
}
Very simple. On an iPad Pro (12.9-inch) (3rd generation)
runs smooth. On an iPad Pro (12.9-inch, 2nd generation) (Model A1670)
it jitters. Both running on iOS 16.1 (20B82)
.
At first I thought it had to do with parts of my app and a bunch of different views I do have in the cell. So I simplified the code down as much as I could to see if even the simplest implementation would cause jitter on the 2nd gen iPad or not.
I also tried to record a video of the two models but it does not show up too well on video so I gave up on that.
Is there a way to make the scroll smoother on older iOS models then? Does this mean that SwiftUI scroll views etc... are simply not going to work well on older model iPads? UIScrollView and UIKit in general scrolls great even with very heavy logic in cells etc.
Does anyone have a fix to improve scroll performance of this code on older iOS devices models?