0
打我有问题,播放视频的采集观察室视频在多个小区
- 我的问题是我想只有在一个单元播放视频,但它在所有细胞发挥。
- 单元格包含视频和图像。
- 当数据源是图像的时候,我希望图像上的图像视图和视图必须隐藏起来。
- 当数据源是视频网址时,我希望图像在视图和图像视图必须隐藏。
我用下面的代码。
- (UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath {
//[self.collection reloadData];
homeceeCollectionViewCell *cell = [collectionView dequeueReusableCellWithReuseIdentifier:reuseIdentifier forIndexPath:indexPath];
UIImage *image;
NSInteger row = [indexPath row];
NSURL *furl;
NSLog(@"indexpath = %ld", (long)row);
if ([app.array1[row] isKindOfClass:[NSURL class]])
{
furl=app.array1[row];
cell.movieplayer = [[MPMoviePlayerController alloc]initWithContentURL:app.array1[row]];
cell.videoview.hidden=NO;
cell.img.hidden=YES;
cell.movieplayer.view.frame = cell.img.frame;
[cell.videoview addSubview:cell.movieplayer.view];
NSLog(@"%@",cell.movieplayer);
[cell.movieplayer play];
NSLog(@"%@",cell.movieplayer);
}
else {
if ([app.array1[row] isKindOfClass:[UIImage class]]) {
image= app.array1[row];
cell.videoview.hidden=YES;
}
else {
image = [UIImage imageNamed:app.array1[row]];
cell.videoview.hidden=YES;
}
cell.img.image = image;
cell.videoview.hidden=YES;
}
cell.text.text=[app.tarray1 objectAtIndex:indexPath.row];
return cell;
}
- app.array1是包含图像和视频的URL阵列。
- cell.img是我在集合视图单元格中声明的图像视图。
- cell.videoview是我在集合视图单元格中声明的视图。
请帮我解决这个问题,如果这个问题不明确离开我评论,我会为你的答案
感谢您的答案,我想目标C我不知道迅速 –
好了,只需一分钟... –
WR我应该使用这个 –