Swift 3 scrollToRowAtIndexPath became scrollToRow

I am converting a Swift 2.3 project o Swift 3 and digging out literally thousands of changes

I currently have the code:

outletCatalog.scrollToRowAtIndexPath(myIndex, atScrollPoisition: .top, animated: false)

However, it seems to be replaced by

func scrollToRow(at: IndexPath, at: UITableViewScrollPosition, animated: Bool)

However - I do not understand the double name of the "at" parameter, and my Google searches did not return anything. And the code translation tools just show that it has

scrollToRow(at:at:animated)
+4
source share
2 answers

After converting the code from Swift 2.3 to Swift 3.2, you need to call the code below GCD main dispatch blockwith new changes. for the auto scroll bar for the 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 this works for you.

+5
source

API scrollToRow (at: at: :) , , , . IndexPath ( ). , UITableViewScrollPosition, , (// ). .

:

outletCatalog.scrollToRowAtIndexPath(myIndex, atScrollPosition: .top, animated: false)

:

outletCatalog.scrollToRow(at: myIndex, at: .top, animated: false)

. : https://developer.apple.com/reference/uikit/uitableview/1614997-scrolltorow https://developer.apple.com/reference/uikit/uitableviewscrollposition

0

Source: https://habr.com/ru/post/1671646/


All Articles