I am converting a Swift 2.3 project o Swift 3 and digging through literally thousands of changes
I currently have code like this:
outletCatalog.scrollToRowAtIndexPath(myIndex, atScrollPoisition: .top, animated: false)
However, it is apparently replaced by
func scrollToRow(at: IndexPath, at: UITableViewScrollPosition, animated: Bool)
However - I don't understand the double parameter naming of "at" and my Google searches did not yield anything. And code translation tools just shows it has
scrollToRow(at:at:animated)
After code conversion from Swift 2.3 to Swift 3.2 version, you need to call below code inside GCD main dispatch block
with the new changes for auto scroll row to index.
DispatchQueue.main.async {
let index = IndexPath(row: 10, section: 0) // use your index number or Indexpath
self.tableCart.scrollToRow(at: index,at: .middle, animated: true) //here .middle is the scroll position can change it as per your need
}
I hope it will work for you.
Support - Swift 3.1, 3.2, 4.1
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With