1

我很难尝试UISlider在我的应用上替换播放不可见MPMoviePlayerControllerUIProgressView.

UISlider只是创建,更改非常直观,几乎在更新选择器上从MPMoviePlayerController我更新其当前状态:

之前我从以下内容定义了最小值和最大值MPMoviePlayerController

-(void)UpdateTime:(NSTimer*)Timer
{

[self.sldProgress1 setValue:[[NSNumber numberWithDouble:playerSong.currentPlaybackTime] floatValue]];

}

UIProgressView没有提供类似的方法,我也没有在网上找到与我正在尝试做的事情相匹配的样本:

        sldProgress2.maximumValue = [playerSong playableDuration];
        sldProgress1.value = 0.0;

有什么建议么?

4

2 回答 2

1

UIProgressView doesn't have the concept of a user-settable max value - it's just 100.0. To make it work as you want, you'll have to do some math. Luckily, it's easy math:

CGFloat percentComplete = [playerSong.currentPlaybackTime floatValue] / [playerSong.playableDuration floatValue];

That will give you the percentage of the song that's complete, and you just update your UIProgressView to that number.

progressView.progress = percentComplete;

More or less - this code was mostly pseudo based on your question, but that's the idea.

于 2013-07-06T15:08:53.077 回答
0

您可以继续使用 UISlider 并使用以下行隐藏 thumbImage:

[mySlider setThumbImage:[[UIImage alloc] init] forState:UIControlStateNormal];

这对我有用。

于 2013-07-01T04:12:49.470 回答