-
Notifications
You must be signed in to change notification settings - Fork 235
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Added snapping capability #17
Comments
P.S. Small mistake... If "stepValue" is not set in viewDidLoad: In from "UITableViewController" derived class:
In "ASValueTrackingSlider.m":
Appicus. |
Hi @appicus, thanks for your contribution. I'm wondering whether there is a simpler way of achieving the same objective? Let's assume there's a slider with // connect this action to 'Touch Up Inside' in the Storyboard
- (IBAction)snapValue:(UISlider *)slider
{
[slider setValue:lroundf(slider.value) animated:YES];
} If custom labels need to be displayed for the 5 slider values, something like this should work: - (void)viewDidLoad
{
self.popUpLabels = @[@"A", @"B", @"C", @"D", @"E"];
self.slider.minimumValue = 0;
self.slider.maximumValue = 4;
}
// WARNING: this dataSource method doesn't exist yet!!!
- (NSString *)progressView:(ASProgressPopUpView *)progressView stringForValue:(float)value;
{
NSUInteger i = lroundf(value);
return self.popUpLabels[i];
} Let me know if this is useful, or if I have misunderstood the problem. Cheers, |
I've tried your suggestion with:
but the problem is, that the popUp label is not exactly following the slider when it "snaps" to an integer value. The other reason why I prefer to use my solution is that I am able to set the steps as float, so that I can also "snap" every 0.2 steps or so. But I will be very glad when you implement something like:
That would be great! The idea with "self.popUpLabels" array is exactly what would be useful in this case:
Thanks again, |
Hi Kenan, - (void)setValue:(float)value animated:(BOOL)animated
{
if (NSFoundationVersionNumber > NSFoundationVersionNumber_iOS_6_1) {
[super setValue:value animated:animated];
[self positionAndUpdatePopUpView];
}
else {
[UIView animateWithDuration:0.25 animations:^{
[super setValue:value animated:animated];
[self positionAndUpdatePopUpView];
}];
}
} The current implementation only updates the popUpView if |
What exactly my problem is I can't adjust the size of popUpView size for a String. You do it with NSNumberFormatter like this:
How can I modify this method to send a String instead of:
EDIT:
I got this issue: ... just "Lore" instead of full string "Lorem Ipsum". Thanks! |
I've just published another branch https://github.com/alskipp/ASValueTrackingSlider/tree/custom_string It has a first draft implementation of: @protocol ASValueTrackingSliderDataSource <NSObject>
- (NSString *)slider:(ASValueTrackingSlider *)slider stringForValue:(float)value;
@end It was a very quick hack, so I can't guarantee it's perfect just yet! You just need to adopt the protocol - (NSString *)slider:(ASValueTrackingSlider *)slider stringForValue:(float)value; Let me know if it works as I've barely tested it myself! |
Great stuff! I'm glad it's working. 👍 Good luck with your app. |
Hello again,
Sorry, I don't know how to commit my own enhancements, but I added a snapping capability to your project, this way:
In "ASValueTrackingSlider.h":
In "ASValueTrackingSlider.m":
valueChanged must be called from UITableViewController when the slider changes its value ( connect an action from slider in storyboard for Value Changed and name it sliderValueChanged)
In your UITableViewController class:
In viewDidLoad of your UITableViewController
Greetings from Berlin
Kenan.
The text was updated successfully, but these errors were encountered: