在播放音频剪辑时,我需要在UIProgressBar中显示UITableviewCell。
我试着运行一个NSTimer,然后尝试更新进度视图,但它不起作用。这是我的密码。请告诉我这种方法有什么问题。
运行计时器
self.timer = [NSTimer scheduledTimerWithTimeInterval:0.25
target:self
selector:@selector(updatePlayProgress)
userInfo:nil
repeats:YES];在TableviewCell中更新UIProgressView
- (void)updatePlayProgress {
AppDelegate *appDelegate = (AppDelegate *)[[UIApplication sharedApplication] delegate];
NSLog(@"Duration %f", appDelegate.moviePlayer.duration);
NSLog(@"Current time %f", appDelegate.moviePlayer.currentPlaybackTime);
float timeLeft = appDelegate.moviePlayer.currentPlaybackTime/appDelegate.moviePlayer.duration;
// upate the UIProgress
NSIndexPath *indexPath = [NSIndexPath indexPathForRow:playingIndex inSection:0];
FeedCell *cell = (FeedCell*)[self tableView:self.tblView cellForRowAtIndexPath:indexPath];
NSLog(@"Time left %f", timeLeft);
cell.progressPlay.progress = 0.5;
[cell.progressPlay setNeedsDisplay];
}CellForRowAtIndexPath
fCell.progressPlay.alpha = 0.5;
fCell.progressPlay.tintColor = navigationBarColor;
[fCell.progressPlay setTransform:CGAffineTransformMakeScale(fCell.frame.size.width, fCell.frame.size.height)];
[fCell.progressPlay setHidden:NO];
return fCell;输出应该类似于

发布于 2015-07-02 17:46:50
在将近两天后,终于发现了这个问题:( :(错误在这一行中)
错误
NSIndexPath *indexPath = [NSIndexPath indexPathForRow:playingIndex inSection:0];
FeedCell *cell = (FeedCell*)[self tableView:self.tblView cellForRowAtIndexPath:indexPath];校正
NSIndexPath *indexPath = [NSIndexPath indexPathForRow:playingIndex inSection:0];
FeedCell *cell = (FeedCell*)[self.tblView cellForRowAtIndexPath:indexPath]; 发布于 2015-06-30 16:24:25
当您调用[self.tblView reloadData]时,您将进度条设置为0.0,在下面的fCell.progressPlay.progress = 0.0行中。删除对reloadData的调用。
https://stackoverflow.com/questions/31142393
复制相似问题