UISLider设置thumb/minimumTrack/maximumTrack色调颜色出现异常

发布于 2024-12-16 18:53:43 字数 1540 浏览 0 评论 0 原文

根据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;
}

According to developer.apple I should be able to set UISLider's property - thumbTintColor/minimumTrackTintColor/maximumTrackTintColor - reference http://developer.apple.com/library/IOs/#documentation/UIKit/Reference/UISlider_Class/Reference/Reference.html

But setting any of these properties raises "unrecognized selector sent to instance" exception.

I know there is a workaround for this by setting image properties. But I don't want to go that way. Is there anything I'm missing?

Please any help is appreciated. Thanks in advance.

Here is the code from UICatalog project of developer.apple examples:

- (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;
}

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

似最初 2024-12-23 18:53:43

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

You are trying to do this on not iOS5 devices/simulators. The API you want to use are only available on iOS5.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文