ios - adjusting label to slider value swift -
i have slider , label in swift project. on storyboard, control dragged slider onto controller class page , created outlet , action. control dragged label outlet. trying update label based on slider's value. don't know going wrong.
code:
@iboutlet weak var slider: uislider! @iboutlet weak var sliderval: uilabel! @ibaction func slidervaluechanged(sender: uislider) { var currentvalue = int(sender.value) println("slider changing \(currentvalue) ?") sliderval.text = "\(currentvalue) km" }
i can see in log slidervaluechanged funciton being called , log printing value label's text not updating. doing wrong?
update:
i put slider object , label on login screen , used same methodology , code change label text , worked not work inside tab bar controller. shed light on issue may be?
update slider value in main queue
@ibaction func slidervaluechanged(sender: uislider) { var currentvalue = int(sender.value) println("slider changing \(currentvalue) ?") dispatch_async(dispatch_get_main_queue(){ sliderval.text = "\(currentvalue) km" }) }
i hope helpful you.
Comments
Post a Comment