我有一個tableView
它列出了包含jpg和mp4文件的內容目錄。iPhone - UITableView到DetailView
當前當您選擇任何mp4文件時,它會加載MPMovieController
並相應播放正確的文件,但如果文件的擴展名爲JPG,我不確定如何加載詳細視圖。
例如,如果tableView
中選定的文件是圖像文件,它將在detailView
中打開imageView
以顯示該圖像。
對於其他文件,它推送一個alertView
關於它是未知文件。
這是代碼我迄今爲tableview didSelectRowAtIndex
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{static NSString *CellIdentifier = @"Cell";
UITableViewCell *cell = [tableView
dequeueReusableCellWithIdentifier:CellIdentifier];
NSString *urlString = [NSString stringWithFormat:@"http://10.1.4.3:8080/DCIM/DCIM/VIDEO/%@",[movieArray objectAtIndex:indexPath.row]];
//Play multiple video
NSURL *url = [NSURL URLWithString:[urlString stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding]];
_moviePlayer = [[MPMoviePlayerController alloc]
initWithContentURL:url];
[[NSNotificationCenter defaultCenter] addObserver:self
selector:@selector(moviePlayBackDidFinish:)
name:MPMoviePlayerPlaybackDidFinishNotification
object:_moviePlayer];
_moviePlayer.controlStyle = MPMovieControlStyleDefault;
_moviePlayer.shouldAutoplay = YES;
[self.view addSubview:_moviePlayer.view];
[_moviePlayer setFullscreen:YES animated:YES];}
任何鏈接或源代碼將是非常方便的。
謝謝。
這意味着您不知道在加載單元格時單元格可以包含的文件類型? –
@RatikantaPatra單元顯示正確,mp4文件正在加載,但是我需要它在選擇JPG時轉到詳細視圖。 – teejay
你需要有你自己的定製詳細視圖,其中將包含一個imageView裏面保存相應的JPG圖像。 –