1
根据developer.apple我应该能够设置UISLider的财产 - thumbTintColor/minimumTrackTintColor/maximumTrackTintColor - 参考http://developer.apple.com/library/IOs/#documentation/UIKit/Reference/UISlider_Class/Reference/Reference.htmlUISLider设置拇指/ minimumTrack/maximumTrack着色颜色变得异常
但设置这些属性引发“无法识别的选择发送到实例“异常。
我知道这是通过设置图像属性的解决方法。但我不想那样。有什么我失踪?
请任何帮助表示赞赏。提前致谢。
这里是从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;
}
谢谢,你说得对。我刚刚测试过。当我选择iOS 5模拟器时,它的工作很好。但用
iEamin
除非你自己烘烤,否则你不能在ios 4上获得这个。但是你可以使用respondsToSelector来拥有通用代码。他们在4点和5点之间会有所不同 –