尝试将我的视频放在UITableViewCell中的自定义视图中。
videoView是一个UIView:
以下是选择单元格时:
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
FeedCustomCell *cell = [[FeedCustomCell alloc] init];
NSURL *url = [NSURL URLWithString:_videoPathString];
moviePlayer = [[MPMoviePlayerController alloc] initWithContentURL:url];
moviePlayer.controlStyle = MPMovieControlStyleNone;
CGRect previewFrame = CGRectMake(cell.videoView.frame.origin.x,
cell.videoView.frame.origin.y,
cell.videoView.frame.size.width,
cell.videoView.frame.size.height);
moviePlayer.view.frame = previewFrame;
moviePlayer.repeatMode = MPMovieRepeatModeOne;
[self.view addSubview:moviePlayer.view];
[self.view bringSubviewToFront:moviePlayer.view];
[moviePlayer play];
}
这是我的手机:
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
static NSString *CellIdentifier = @"FeedCustomCell";
FeedCustomCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
// Configure the cell...
cell.username.text = [NSString stringWithFormat:@"%@", _usernameString];
cell.createdDate.text = [NSString stringWithFormat:@"%@", _createdString];
return cell;
}
我只在选择单元格时向cell.videoView添加内容。我做错了吗?
视频正在播放声音,但没有视觉效果。
答案 0 :(得分:0)
而不是:
[self.view addSubview:moviePlayer.view];
试试这个:
[self.view.contentView addSubview:moviePlayer.view];