سؤال

TL;DR: what I am looking for is a link or code for a UI control that allows me to select a data set range.

I'm developing an iPad application with a specific section that looks at a set of data over a period of time. I would like to give the user the option of modifying the data set using a range selection UI control. I googled various UI Range selectors or UI Sliders with dual sliders but every example I found is old and does not work well with iOS 7 (as in usability of the control).

I did find a very good example on the Mint iPad application that looks like this: enter image description here

Here's a few example I've found that did not work properly:

هل كانت مفيدة؟

المحلول

So I ended up finding a viable solution using the github project from romaonthego (https://github.com/romaonthego/RETrimControl)

In order to modify this project to look at a specific time range within a day, I changed the max value to 86400 (seconds in a day) and convert the value from each slider event like so:

NSCalendar *calendar = [[NSCalendar alloc] initWithCalendarIdentifier:NSGregorianCalendar];
    NSDateComponents *components = [[NSDateComponents alloc] init];
    [components setYear:2014];
    [components setMonth:1];
    [components setDay:1];
    [components setHour:0];
    [components setMinute:0];
    NSDate *myDate = [calendar dateFromComponents:components];
    myDate = [myDate dateByAddingTimeInterval:_leftValue];

    NSDateFormatter *formatter = [[NSDateFormatter alloc]init];
    [formatter setDateFormat:@"hh:mm a"];


    NSString *dateString = [formatter stringFromDate:myDate];

    _leftPopover.timeLabel.text = [NSString stringWithFormat:@"%@",dateString];

The project allows the use of using a resource bundle as well for customizing the control. I hope this helps anyone who is looking for a similar control!

مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top