1
我需要在選擇標籤欄項目時一直向上滾動表格視圖。 我試過這個,但它不起作用。當點擊標籤欄時,將桌面向上滾動到頂部
func tabBarController(_ tabBarController: UITabBarController, didSelect viewController: UIViewController) {
let tabBarIndex = tabBarController.selectedIndex
if tabBarIndex == 0 {
let indexPath = NSIndexPath(row: 0, section: 0)
MyViewController().tableView.scrollToRow(at: indexPath as IndexPath, at: .top, animated: true)
}
}
該方法被調用,但tableView不滾動到頂部。