[iOS] UITableView 특정한 위치로 스크롤 이동

모리스·2023년 11월 16일
0

iOS

목록 보기
9/14
post-thumbnail

이번 노트는 간단하게 UITableView의 scroll에서 특정 IndexPath로 scroll되는 방법을 기술하려한다.
방법은 간단하다.
tableView의 scrollToRow를 사용하여 특정 IndexPath로 scroll 되게 할 수 있다.

let indexPath = IndexPath(row: 0, section: 0)
self.tableView?.scrollToRow(at: indexPath, at: UITableView.ScrollPosition.top, animated: true)

이렇게하면 indexPath의 row와 section을 모두 0번째로 설정해 tableView의 최상단으로 scroll 된다.

profile
모바일 앱 개발 노트 :)

0개의 댓글