-1

我有一个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];
    }
4

1 回答 1

0

当视频播放器打开时,presentmodalviewcontroller 被打开,当您按下完成按钮时,它会关闭 modalviewcontroller,因此您初始化的任何内容都会被释放,并再次调用整个视图,以避免在 viewwillappear 方法中编写代码。

当您再次按下完成按钮时,它将创建表格视图,这是您关闭任何控制器时的唯一解决方案。在 viewwillappear 方法中使用

NSLog(@"");

声明你会知道我想说什么

于 2013-07-26T06:07:06.170 回答