내 주요 목표는 테이블보기 항목을 클릭하고 비디오를로드 할 수 있습니다.비디오 재생하기 UITableView
void)viewDidLoad
{
[super viewDidLoad];
NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
NSString *documentsDirectory = [paths objectAtIndex:0]; // Get documents folder
NSString *dataPath = documentsDirectory;
filePathsArray = [[NSFileManager defaultManager] subpathsOfDirectoryAtPath:dataPath error:nil];
}
-(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
return [filePathsArray count];
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
static NSString *simpleTableIdentifier = @"SimpleTableCell";
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:simpleTableIdentifier];
if (cell == nil) {
cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:simpleTableIdentifier];
}
cell.textLabel.text = [filePathsArray objectAtIndex:indexPath.row];
return cell;
}
그러나 파트 I : 테이블 뷰가 문서 디렉토리의 내용으로 채워집니다 내가 성공적으로이 작업을 수행 할 셀의 레이블에 파일 이름을 추가 할 수 있었다, 나는 다음과 같은 코드를 사용하여이 작업을 수행 한 어려운 부분을 찾는 것은 파일 부분을 여는 것입니다. 이것은 지금까지 내 코드입니다 : jQuery과 셀에 사용자가 클릭으로 비디오 플레이어를 전체 화면으로 열리도록하고 그냥 말할 때 어떻게됩니까
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
NSLog(@"didSelectRowAtIndexPath");
myURL=[NSURL URLWithString:[filePathsArray objectAtIndex:indexPath.row]];
MPMoviePlayerController *moviePlayerController = [[MPMoviePlayerController alloc] initWithContentURL:myURL];
[self.view addSubview:moviePlayerController.view];
moviePlayerController.fullscreen = YES;
[moviePlayerController play];
[self setController:moviePlayerController];
[tableView deselectRowAtIndexPath:indexPath animated:YES];
}
"로드 ..."전체 시간과 비디오하지 않습니다 로드 할 때 디버거에서 오류가보고되지 않습니다. 변수 myURL을 어떻게 설정해야합니까? 어떤 도움이라도 대단히 감사하겠습니다.
moviePlayer는 .h 파일의 속성이며 다음과 같습니다. @property (비 원자, 읽기 전용) MPMoviePlayerController * moviePlayer; – jjdoherty