[UIKit] 스크롤뷰/테이블뷰 제일 밑으로 이동
2022. 8. 6. 23:35ㆍiOS/UIKit
728x90
반응형
테이블뷰
데이터 불러오기 -> 테이블에 데이터 추가 -> 테이블뷰 리로드 -> 제일 밑으로 이동
self.chatResult += chatresult
self.chatTableView.reloadData()
self.scrollToBottom()
func scrollToBottom(){
DispatchQueue.main.async {
if self.chatResult.count > 0 {
let ip = IndexPath(row: self.chatResult.count-1, section: 0)
self.chatTableView.scrollToRow(at: ip, at: .bottom, animated: true)
}
}
refreshControl.endRefreshing()
}
꼭 비동기로 진행해줘야함!!!!
https://dreamaz.tistory.com/350
Swift UITableView 마지막 행으로 이동
안녕하세요. 개발자 드리머즈입니다. Swift에서 UITableView를 다루다보면 scroll을 마지막으로 이동하고 싶을 때가 있습니다.(scroll to bottom) 저의는 UITableView가 section과 row를 다 보여주고나서 마지막..
dreamaz.tistory.com
스크롤뷰
extension UIScrollView {
func scrollToBottom() {
let offset = CGPoint(
x: 0,
y: contentSize.height - bounds.height
)
setContentOffset(offset, animated: false)
}
}
728x90
반응형
'iOS > UIKit' 카테고리의 다른 글
[UIKit] 로컬푸시 알림구현 (0) | 2022.08.07 |
---|---|
[UIKit] 컬렉션뷰 왼쪽정렬 (0) | 2022.08.07 |
[UIKit] 텍스트필드 입력(클릭) 시 키보드 올리기/내리기 (0) | 2022.08.06 |
[UIKit] "keyWindow' was deprecated in iOS 13.0 : Should not be used for applications that support multiple scenes as it returns a key window across all connected scenes" error 에러 해결 (0) | 2022.08.06 |
[UIKit] 위에서 올라오는 바텀시트(모달창) 만들기 (FloatingPanel 라이브러리) (0) | 2022.08.06 |