UISlider *slider = [[UISlider alloc] initWithFrame:CGRectMake(60, 100, 200, 20)]; ide
slider.tag = 101; get
slider.maximumValue = 10; it
slider.minimumValue = 0; io
[slider addTarget:self action:@selector(change:) forControlEvents:UIControlEventValueChanged]; test
[slider addTarget:self action:@selector(touchUpInside:) forControlEvents:UIControlEventTouchUpInside]; select
[slider addTarget:self action:@selector(test1) forControlEvents:UIControlEventTouchDragInside]; 方法
[slider addTarget:self action:@selector(test2) forControlEvents:UIControlEventTouchDragOutside]; im
[self.view addSubview:slider]; touch
[slider release]; animate
[NSTimer scheduledTimerWithTimeInterval:1 target:self selector:@selector(test:) userInfo:slider repeats:NO];
//監聽方法
- (void)change:(UISlider *)slider
{
NSLog(@"slider value : %.2f", slider.value);
}
- (void)touchUpInside:(UISlider *)slider
{
NSLog(@"touchUpInside : %.2f", slider.value);
}
- (void)test:(NSTimer *)timer
{
UISlider *slider = [timer userInfo];
[slider setValue:5 animated:NO];
}
- (void)test1
{
NSLog(@"test1");
}
- (void)test2
{
NSLog(@"test2");
}