【问题标题】:UISLider setting thumb/minimumTrack/maximumTrack tint color gets exceptionUISLider 设置 thumb/minimumTrack/maximumTrack tint color 获取异常
【发布时间】:2011-11-16 07:02:28
【问题描述】:

根据 developer.apple 我应该能够设置 UISLider 的属性 - thumbTintColor/minimumTrackTintColor/maximumTrackTintColor - 参考http://developer.apple.com/library/IOs/#documentation/UIKit/Reference/UISlider_Class/Reference/Reference.html

但是设置这些属性中的任何一个都会引发“无法识别的选择器发送到实例”异常。

我知道通过设置图像属性可以解决此问题。但我不想走那条路。我有什么遗漏吗?

请提供任何帮助。提前致谢。

这是来自 developer.apple 示例的 UICatalog 项目的代码:

- (UISlider *)sliderCtl
{
    if (sliderCtl == nil) 
    {
        CGRect frame = CGRectMake(174.0, 12.0, 120.0, kSliderHeight);
        sliderCtl = [[UISlider alloc] initWithFrame:frame];
        [sliderCtl addTarget:self action:@selector(sliderAction:) forControlEvents:UIControlEventValueChanged];

        // in case the parent view draws with a custom color or gradient, use a transparent color
        sliderCtl.backgroundColor = [UIColor clearColor];

        // I just added this following line to test
        sliderCtl.thumbTintColor = [UIColor yellowColor];

        sliderCtl.minimumValue = 0.0;
        sliderCtl.maximumValue = 100.0;
        sliderCtl.continuous = YES;
        sliderCtl.value = 50.0;

        // Add an accessibility label that describes the slider.
        [sliderCtl setAccessibilityLabel:NSLocalizedString(@"StandardSlider", @"")];

        sliderCtl.tag = kViewTag;   // tag this view for later so we can remove it from recycled table cells
    }
    return sliderCtl;
}

【问题讨论】:

    标签: iphone ios exception uislider tintcolor


    【解决方案1】:

    您尝试在非 iOS5 设备/模拟器上执行此操作。您要使用的 API 仅适用于 iOS5。

    【讨论】:

    • 谢谢,你是对的。我现在刚刚测试过。当我选择 iOS 5 模拟器时,它工作正常。但是
    • 除非您自己烘焙,否则您无法在 ios 4 上获得此功能。但是您可以使用 respondsToSelector 来获得通用代码。它们只会在 4 和 5 之间有所不同
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2015-06-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2023-04-06
    • 2014-05-30
    相关资源
    最近更新 更多