-1

私はUITableViewカスタムセルを持っています.この表では、ビデオのリストは、ページネーションの概念を使用してサーバーから10 x 10で表示されています. ビデオ リストをクリックすると、moviePlayerController でビデオの再生が開始されますが、ButtonmoviePlayerController の完了をクリックすると、ビデオ リストが更新されます。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メソッドにコードを記述しないようにします。

完了ボタンをもう一度押すと、テーブルビューが作成されます。これが、コントローラーを閉じるときの唯一の解決策です。In viewwillappear メソッドの使用

NSLog(@"");

私が言おうとしていることをあなたが知るようになる声明

于 2013-07-26T06:07:06.170 に答える