Edit ViewController.swift as below:
import UIKit
class ViewController: UIViewController, UITableViewDataSource, UITableViewDelegate {
var tableView : UITableView!
var tableRowNumber : Int = 5
var refreshControl : UIRefreshControl!
override func viewDidLoad() {
super.viewDidLoad()
tableView = UITableView(frame: CGRectMake(0, 30, view.bounds.width, 400))
tableView.dataSource = self
tableView.delegate = self
view.addSubview(tableView)
refreshControl = UIRefreshControl()
refreshControl.addTarget(self, action: Selector("enlargeTable"), forControlEvents: UIControlEvents.ValueChanged)
tableView.addSubview(refreshControl)
}
func enlargeTable() {
tableRowNumber += 5
tableView.reloadData()
refreshControl.endRefreshing()
}
func tableView(tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
return tableRowNumber
}
func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell {
let cell = UITableViewCell(style: UITableViewCellStyle.Default, reuseIdentifier: "myIdentifier")
cell.textLabel?.text = "\(indexPath.row)"
return cell
}
override func didReceiveMemoryWarning() {
super.didReceiveMemoryWarning()
}
}
=========================
Related Post:
https://www.youtube.com/watch?feature=player_embedded&v=eAmEaBVmqos
ReplyDelete