2014-06-23 2 views
-1

오디오 플레이어를 구현 중입니다. 하지만 내 슬라이더가 끌리지 않습니다.UISlider가 iOS를 끌지 않습니다.

/* 
* Sets the current value of the slider/scrubber 
* to the audio file when slider/scrubber is used 
*/ 
- (IBAction)setCurrentTime:(id)scrubber { 
    //if scrubbing update the timestate, call updateTime faster not to wait a second and dont repeat it 

    NSLog(@"%@scrubber",@"drag"); 

    [NSTimer scheduledTimerWithTimeInterval:0.01 
            target:self 
            selector:@selector(updateTime:) 
            userInfo:nil 
            repeats:NO]; 

    [self.audioPlayer setCurrentAudioTime:self.currentTimeSlider.value]; 
    self.scrubbing = FALSE; 
} 

/* 
* Sets if the user is scrubbing right now 
* to avoid slider update while dragging the slider 
*/ 
- (IBAction)userIsScrubbing:(id)sender { 
    NSLog(@"%@",@"slider drag"); 

    self.scrubbing = TRUE; 
} 

/* 
* Updates the time label display and 
* the current value of the slider 
* while audio is playing 
*/ 
- (void)updateTime:(NSTimer *)timer { 
    //to don't update every second. When scrubber is mouseDown the the slider will not set 
    if (!self.scrubbing) { 
     //self.currentTimeSlider.value = [self.audioPlayer getCurrentAudioTime]; 
    } 

     NSLog(self.scrubbing ? @"Yes" : @"No"); 

    if(self.scrubbing) 
    { 
     NSLog(@"%@ scrubbing",@"sdfs"); 
    } 
    [self.currentTimeSlider addTarget:self 
        action:@selector(sliderDidEndSliding:) 
     forControlEvents:(UIControlEventTouchUpInside | UIControlEventTouchUpOutside)]; 

    long currentPlaybackTime = [self.audioPlayer getCurrentAudioTime]; 
    self.currentTimeSlider.value = currentPlaybackTime/[self.audioPlayer getAudioDuration]; 

    self.timeElapsed.text = [NSString stringWithFormat:@"%@", 
          [self.audioPlayer timeFormat:[self.audioPlayer getCurrentAudioTime]]]; 

    self.duration.text = [NSString stringWithFormat:@"%@", 
          [self.audioPlayer timeFormat:[self.audioPlayer getAudioDuration] - [self.audioPlayer getCurrentAudioTime]]]; 
} 

이 슬라이더는 우리가 이전 위치로 이동 슬라이더를 드래그해도 드래그하지 않습니다 .H

@property (strong, nonatomic) IBOutlet UISlider *currentTimeSlider; 
@property BOOL scrubbing; 

하는 .m

. 왜 슬라이더가 드래그되지 않는지에 대한 아이디어.

감사합니다,

+0

모든 아이디어 plssss – asifa

답변

0

안녕하세요 유 YESUISlidercontinuous 속성을 설정했다. 이 때마다 슬라이더 값을 변경할 것입니다. 그 값을 NO에게 줄 것입니다.

[mySlider addTarget:self action:@selector(sliderValueChanged:) forControlEvents:UIControlEventValueChanged]; 

- (IBAction)sliderValueChanged:(UISlider *)sender { 
    NSLog(@"slider value = %f", sender.value); 
} 

유 슬라이드 이벤트를 처리나요?

AND

어디 유 호출 sliderDidEndSliding이 방법이다.

관련 문제