Last active
July 4, 2018 02:14
-
-
Save JeremyXue77/18a114c35a62e238a263b078f9971ac4 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| func loadData(){ | |
| // 這邊我們用一個延遲讀取的方法,來模擬網路延遲效果(延遲3秒) | |
| DispatchQueue.main.asyncAfter(deadline: DispatchTime.now() + 3) { | |
| // 停止 refreshControl 動畫 | |
| self.refreshControl.endRefreshing() | |
| // 新建5筆假資料 | |
| for _ in 1...5 { | |
| self.data.append(self.data.count + 1) | |
| self.myTableView.insertRows(at: [[0,self.data.count - 1]], with: UITableViewRowAnimation.fade) | |
| } | |
| // 滾動到最下方最新的 Data | |
| self.myTableView.scrollToRow(at: [0,self.data.count - 1], at: UITableViewScrollPosition.bottom, animated: true) | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment