【发布时间】:2014-02-21 15:56:49
【问题描述】:
试图将我的视频放在 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 添加一些内容。我做错了吗?
视频播放有声音,但没有视觉效果。
【问题讨论】:
标签: ios objective-c uitableview mpmovieplayer