การทำ pull to refresh คือ การสไลด์ลาก table เลื่อนลงมาลักษณะตามในรูปข้างบนนะครับ เมื่อลงจนสุดจะมีการทำ refresh ข้อมูลในตารางใหม่ วิธีการทำดูจากในโค้ดข้างล่างได้เลยครับ
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 |
var refreshControl: UIRefreshControl! override func viewDidLoad() { super.viewDidLoad() refreshControl = UIRefreshControl() refreshControl.attributedTitle = NSAttributedString(string: "Pull to refresh") refreshControl.addTarget(self, action: "refresh:", forControlEvents: UIControlEvents.ValueChanged) tableView.addSubview(refreshControl) // not required when using UITableViewController } func refresh(sender:AnyObject) { // Code to refresh table view refreshControl.endRefreshing() } |
0