2011-09-25 40 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