Skip to content

Instantly share code, notes, and snippets.

@delboy1978uk
Created May 12, 2015 04:04
Show Gist options
  • Save delboy1978uk/1633d6ef13401202ad4a to your computer and use it in GitHub Desktop.
Save delboy1978uk/1633d6ef13401202ad4a to your computer and use it in GitHub Desktop.
import UIKit
class ViewController: UIViewController, UITableViewDelegate
{
@IBOutlet weak var number: UILabel!
@IBOutlet weak var slider_value: UISlider!
@IBOutlet weak var table: UITableView!
@IBAction func sliderMoved(sender: AnyObject)
{
var val = Int(slider_value.value)
number.text = "\(val)"
table.reloadData()
}
override func viewDidLoad()
{
super.viewDidLoad()
}
override func didReceiveMemoryWarning() {
super.didReceiveMemoryWarning()
// Dispose of any resources that can be recreated.
}
func getValue() -> String
{
return "\(Int(slider_value.value))"
}
func tableView(tableView: UITableView, numberOfRowsInSection section: Int) -> Int
{
return 12;
}
func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell
{
var cell = UITableViewCell(style: UITableViewCellStyle.Default, reuseIdentifier: "cell")
var val = Int(slider_value.value) * (indexPath.item + 1)
cell.textLabel?.text = "\(val)"
return cell
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment