I am trying to scroll the image in tabbar, but i am unable to get the onchange when the image is scrolled.
@State private var currentIndex = 0
TabView(selection: $currentIndex) {
ForEach(model, id: \.self) { detail in
Image(uiImage: detail.image)
.resizable()
.ignoresSafeArea()
.frame(width: 100,height: 100,alignment: .center)
.aspectRatio(contentMode: .fill)
}
}
.onChange(of: currentIndex) { _ in
print("*********")
print(currentIndex)
}
XCode Version: 15.2
You need to change to
ForEach(0..<model.count) { i inthe complete code