Slider with real time in Label (but setting the slider with time from label)

Just implemented this post : Slider with real time in Label

With Denis code and works fine. Thanks.

Just translated to Swift, if anybody want:

func timeSlider(aSlider: UISlider)-> String {
    let numberOfSlots = 24*4 - 1
    let dateFormat = NSDateFormatter()
    dateFormat.dateFormat = "h-mm"
    let zeroDate = dateFormat.dateFromString("00-00")
    let actualSlot = roundf(Float(numberOfSlots)*Float(aSlider.value))
    let slotInterval:NSTimeInterval = NSTimeInterval(actualSlot * 15 * 60)
    let slotDate: NSDate = NSDate(timeInterval: slotInterval, sinceDate: zeroDate!)
    dateFormat.dateFormat = "h-mm"
    return dateFormat.stringFromDate(slotDate)

Now I'm trying to figure out how make the inverse operation. I mean, in my database I'll store the time, shown on label. When I query the database, how can I set the slider ?

My slider is showing values like:

2015-08-21 20:46:14.831 [5306:1205420] 0.303571

2015-08-21 20:46:14.847 [5306:1205420] 0.292411

2015-08-21 20:46:14.864 [5306:1205420] 0.276786

While my slider has minumum = 0 and maximum = 1

Any help ?

Thank you


UISlider has a method - setValue:animated: that you can use to move the slider

Here is the documentation


In order to convert the time value to a value appliable to the slider you need to do the following:

(dbTime - minTime) / (maxTime - minTime)

as long as the dbTime is inbetween the min and max value, it will give a value between 0 and 1

Need Your Help

Backbone JS - Set model attribute node object with value

javascript jquery backbone.js

So the title is a little confusing, I think, but here's the issue:

Foreign Key in SQL pivot table - database design

mysql sql database foreign-keys

I am using DBDesigner 4 for designing my database relations.

About UNIX Resources Network

Original, collect and organize Developers related documents, information and materials, contains jQuery, Html, CSS, MySQL, .NET, ASP.NET, SQL, objective-c, iPhone, Ruby on Rails, C, SQL Server, Ruby, Arrays, Regex, ASP.NET MVC, WPF, XML, Ajax, DataBase, and so on.