ios - 如何获得范围 slider 中的最终值?

标签 ios objective-c rangeslider

我正在使用 TT 范围 slider (双 slider )来过滤我的应用程序中的价格,一切都工作完美,但是当我的最终价格是一些(例如 20)而没有选择 slider 时,我单击应用按钮最终价格是不会出现,并且 slider 选项将达到 0 值(如果有任何答案),我们将不胜感激。提前致谢。 我的代码

float price = [_filterpriceStr floatValue];

NSLog(@"%f",price);

if ([[GlobalVariables appVars].Apply isEqualToString:@"Apply"]) {

    float minimum = [[[NSUserDefaults standardUserDefaults]valueForKey:@"filtermin"] floatValue];
    float maxmum = [[[NSUserDefaults standardUserDefaults]valueForKey:@"filtermax"] floatValue];

    minValue = [[NSUserDefaults standardUserDefaults]valueForKey:@"filtermin"];
    maxValue = [[NSUserDefaults standardUserDefaults]valueForKey:@"filtermax"];

    //standard range slider
    self.rangeSlider.delegate = self;
    self.rangeSlider.minValue = 0;
    self.rangeSlider.maxValue = price;
    self.rangeSlider.step = price;

    self.rangeSlider.selectedMinimum = minimum;
    self.rangeSlider.selectedMaximum = maxmum;

    NSNumberFormatter *customFormatter = [[NSNumberFormatter alloc] init];
    customFormatter.positivePrefix = @"£";
    self.rangeSlider.numberFormatterOverride = customFormatter;
    self.rangeSlider.tintColorBetweenHandles = [UIColor colorWithRed:15.0f/255.0f green:201.0f/255.0f blue:218.0f/255.0f alpha:1.0f];

}
else
{
    float price = [_filterpriceStr floatValue];

    //standard rsnge slider
    self.rangeSlider.delegate = self;
    self.rangeSlider.minValue = 0;
    self.rangeSlider.maxValue = price;
    self.rangeSlider.selectedMinimum = 0;
    self.rangeSlider.selectedMaximum = price;

    NSNumberFormatter *customFormatter = [[NSNumberFormatter alloc] init];
    customFormatter.positivePrefix = @"£";
    self.rangeSlider.numberFormatterOverride = customFormatter;
    self.rangeSlider.tintColorBetweenHandles = [UIColor colorWithRed:15.0f/255.0f green:201.0f/255.0f blue:218.0f/255.0f alpha:1.0f];

}

当点击“应用”按钮时

 [GlobalVariables appVars].PriceRange = @"PriceRange";


[[NSUserDefaults standardUserDefaults]setValue:minValue forKey:@"filtermin"];

[[NSUserDefaults standardUserDefaults]setValue:maxValue forKey:@"filtermax"];

[[NSUserDefaults standardUserDefaults]synchronize];

NSLog(@"%@",maxValue);

[self.navigationController popViewControllerAnimated:NO];

最佳答案

添加此委托(delegate)方法,您将通过它获得最小和最大 slider 值。

 -(void)rangeSlider:(TTRangeSlider *)sender didChangeSelectedMinimumValue:(float)selectedMinimum andMaximumValue:(float)selectedMaximum{

NSLog(@" Min Value: %.0f Max Value: %.0f", selectedMinimum, selectedMaximum);

    [[NSUserDefaults standardUserDefaults]setValue:selectedMinimum forKey:@"filtermin"];

    [[NSUserDefaults standardUserDefaults]setValue:selectedMaximum forKey:@"filtermax"];

 }

关于ios - 如何获得范围 slider 中的最终值?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/53589611/

相关文章:

ios - 如何在swift中声明#pragma pack (1)

iphone - App 更新后 Core Data 轻量级迁移崩溃

c++ - 混合 Objective C ,(*.m , *.mm & .c/.cpp ) 文件

html - 如何解决 ios 中的范围 slider 缩放

javascript - 不使用 jQuery UI 的纯基于 JQuery 的范围 slider

ios - 应用程序 :openURL 的 NSNotificationCentre

android - 加载页面( View )时如何在ionic中播放音频mp3

ios - Xcode 调试检查器将值显示为 nil

objective-c - 如何实现自定义 UIDynamicBehavior 操作

jquery - 如何从 JQuery 中的范围 slider 获取值 - IonRangeSlider?