我有一个UITableView
自定义单元格,在此表中,一个视频列表使用分页概念从服务器显示 10 x 10。当您单击视频列表时,视频开始在 moviePlayerController 中播放,但是当您单击完成Button
的 moviePlayerController 时,您的视频列表将被刷新。我想停止这种刷新,并希望看到UITableView
与播放视频之前相同的内容。
请看代码:
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{
[tableView deselectRowAtIndexPath:indexPath animated:YES];
CurrentVideoIndex =indexPath;
NSDictionary *VideoUrlDic = [videoList objectAtIndex:indexPath.row];
NSString *VideoUrl = [VideoUrlDic objectForKey:@"playUrl"];
//NSLog(@"VideoUrl is ::%@",VideoUrl);
NSURL *fileURL = [NSURL URLWithString:VideoUrl];
moviePlayerController= [[MPMoviePlayerViewController alloc] initWithContentURL:fileURL];
[[moviePlayerController moviePlayer] prepareToPlay];
//[[moviePlayerController moviePlayer] setUseApplicationAudioSession:NO];
[[moviePlayerController moviePlayer] setShouldAutoplay:YES];
//[[moviePlayerController moviePlayer] setControlStyle:2];
//[[moviePlayerController moviePlayer] setRepeatMode:MPMovieRepeatModeOne];
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(videoPlayBackDidFinish:) name:MPMoviePlayerPlaybackDidFinishNotification object:nil];
[self presentMoviePlayerViewControllerAnimated:moviePlayerController];
}
-(void)videoPlayBackDidFinish:(NSNotification*)notification {
[[NSNotificationCenter defaultCenter] removeObserver:self name:MPMoviePlayerPlaybackDidFinishNotification object:nil];
[moviePlayerController.moviePlayer stop];
moviePlayerController = nil;
[[NSNotificationCenter defaultCenter] removeObserver:moviePlayerController name:MPMoviePlayerPlaybackDidFinishNotification object:moviePlayerController.moviePlayer];
if (![[self modalViewController] isBeingDismissed])
{
[self dismissMoviePlayerViewControllerAnimated];
[moviePlayerController.view removeFromSuperview];
[self hideProgress];
}
// [self.tableView scrollToRowAtIndexPath:CurrentVideoIndex atScrollPosition:UITableViewScrollPositionTop animated:NO];
//loading=NO;
}
#pragma UIScroll View Method::
- (void)scrollViewDidEndDecelerating:(UIScrollView *)scrollView
{
if (!loading) {
float endScrolling = scrollView.contentOffset.y + scrollView.frame.size.height;
if (endScrolling >= scrollView.contentSize.height)
{
[self performSelector:@selector(loadDataDelayed) withObject:nil afterDelay:2];
}
}
}
#pragma UserDefined Method:::
-(void)loadDataDelayed{
counter +=10;
NSString *count = [NSString stringWithFormat:@"%d",counter];
NSLog(@"count value after Scrolling is :::%@",count);
[self createConnection:count];
}