2011-09-25 52 views
0

HI我有一个UITableview,当用户点击一个特定的单元格时,我使用MPmovieplayercontroller播放视频,视图正确播放,顶部有一个完成按钮。当我点击完成按钮时,我需要回到主视图控制器,wchih具有UIble视图。请参阅下面的代码,并告诉我可以做些什么。来自UITableview的MPMoviePlayerController

- (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];  
} 

回答

0

我没有测试过这一点,但尝试

[player.navigationItem.rightBarButtonItem setAction:@selector(removeFromSuperview)]; 
[player.navigationItem.rightBarButtonItem setTarget:player.view]; 

的代码只是设置合适的导航项目的选择删除视图从它的上海华。

P.S您可能想要添加动画,因为superview动画的删除很粗糙。

+0

它说“对象MPMovieplayercontroller无法找到属性navigationItem” – UnlimitedMeals

+0

尝试'player.navigationController.navigationItem' –

+0

nope这不起作用。 – UnlimitedMeals