我正在尝试在单元格本身而不是全屏视频显示中播放视频。我正在MPMoviePlayerController
为此目的使用。
我已经定义
MPMoviePlayerController *moviePlayer;
在实施部分
然后在cellForRowAtIndexPath:
我这样做
cell = [tableView dequeueReusableCellWithIdentifier:simpleTableVideoIdentifier];
if (cell == nil){
cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:simpleTableVideoIdentifier];
}
NSDictionary *dictionary = [dataArray objectAtIndex:indexPath.section];
NSDictionary *data = dictionary;
if ([data[@"type_of_post"] isEqualToString:@"video"]) {
NSString *path = data[@"video"];
NSURL *videoURL = [NSURL URLWithString:path];
moviePlayer = [[MPMoviePlayerController alloc] initWithContentURL:videoURL];
[moviePlayer setControlStyle:MPMovieControlStyleNone];
moviePlayer.scalingMode = MPMovieScalingModeAspectFit;
[moviePlayer.view setFrame:CGRectMake(10.0, 0.0, 300.0 , 400.0)];
[cell addSubview:moviePlayer.view];
moviePlayer.view.hidden = NO;
[moviePlayer prepareToPlay];
[moviePlayer play];
}else{
//do something else
}
显然我给它分配了一个高度heightForRowAtIndexPath:
但是它在MPMoviePlayerController *moviePlayer;
全球范围内定义的点并不仅仅停留在其单元格上,而是在我向下滚动时继续下降。除了我所描述的之外,我不确定还有什么其他方法可以实现这一点,这显然不是正确的方法。如果有人能引导我走向正确的方向,我将不胜感激。
谢谢