从UITableview查看MPMoviePlayerController

从UITableview查看MPMoviePlayerController,uitableview,uiviewcontroller,mpmovieplayercontroller,Uitableview,Uiviewcontroller,Mpmovieplayercontroller,您好,我有一个UITableview,当用户单击特定单元格时,我使用MPmovieplayercontroller播放视频,视图将正确播放,顶部有一个“完成”按钮。当我点击“完成”按钮时,我需要返回主视图控制器wchih的UIble视图。请看下面的代码,并建议我可以做什么 - (void)tableView:(UITableView *)tableView accessoryButtonTappedForRowWithIndexPath:(NSIndexPath *)indexPath {

您好,我有一个UITableview,当用户单击特定单元格时,我使用MPmovieplayercontroller播放视频,视图将正确播放,顶部有一个“完成”按钮。当我点击“完成”按钮时,我需要返回主视图控制器wchih的UIble视图。请看下面的代码,并建议我可以做什么

- (void)tableView:(UITableView *)tableView accessoryButtonTappedForRowWithIndexPath:(NSIndexPath *)indexPath {

    NSString *surl = [videoSelected valueForKey:@"video_path"];

    NSLog(@"Video :%@",surl);

    NSURL *url = [NSURL URLWithString:@"http://localhost/MyWorks/files/videos/hit.mp4"];
    MPMoviePlayerController *player =[[MPMoviePlayerController alloc] initWithContentURL: url];
    [[player view] setFrame: [self.view bounds]];  // frame must match parent view
    [self.view addSubview: [player view]];
    [player play];

    [msg release];    
}

我还没有测试过这个,但是试试看

[player.navigationItem.rightBarButtonItem setAction:@selector(removeFromSuperview)];
[player.navigationItem.rightBarButtonItem setTarget:player.view];
代码只是设置了正确导航项的选择器,以从其superview中删除视图


另外,您可能需要添加一个动画,因为删除superview动画比较粗糙。

上面说“在对象MPMovieplayercontroller上找不到属性navigationItem”请尝试
player.navigationController.navigationItem