01/10/2018, 00:02
Swift 3 : Pass data to container view
As title, i’m trying to pass value of slider to containerView but it’s not work
here’s my code:
class ViewController: UIViewController {
@IBOutlet weak var ValueLabel: UILabel!
@IBOutlet weak var sliderControll: UISlider!
override func viewDidLoad() {
super.viewDidLoad()
sliderControll.maximumValue = 5
sliderControll.minimumValue = 0
sliderControll.value = 0
sliderControll.isContinuous = false
self.sliderControll.addTarget(self, action: #selector(ViewController.printData), for: UIControlEvents.valueChanged)
}
func printData(){
ValueLabel?.text = String(self.sliderControll.value)
}
override func prepare(for segue: UIStoryboardSegue, sender: Any?) {
if segue.identifier == "dataID" {
let destination = segue.destination as! SubViewController
destination.myString = (ValueLabel?.text)! as String
}
}
}
thanks!
Bài liên quan
Any error? Have you try to debug it before asking some one? You should give more detail about problems!