ios - 另一个 View 下的 MPMoviePlayerController View

标签 ios uiview uiimageview mpmovieplayercontroller

如果我这样做:

self.productVideo = [[MPMoviePlayerController alloc] initWithContentURL:movieClip];
self.productVideo.controlStyle = MPMovieControlStyleNone;
self.productVideo.shouldAutoplay = YES;
[self.productVideo prepareToPlay];
self.productVideo.repeatMode = MPMovieRepeatModeOne;
self.productVideo.view.frame = self.productImage.frame;
self.productVideo.view.userInteractionEnabled = NO;

[self.view insertSubview:productVideo.view belowSubview:self.productImage];

当我清楚地将它添加到图像下方时,电影出现在图像上方。不能在电影之上叠加图像吗?

最佳答案

您可以尝试将 ImageView 添加到 mp.view,然后再添加 mp.view。如下所示:

self.productVideo = [[MPMoviePlayerController alloc] initWithContentURL:movieClip];
self.productVideo.controlStyle = MPMovieControlStyleNone;
self.productVideo.shouldAutoplay = YES;
[self.productVideo prepareToPlay];
self.productVideo.repeatMode = MPMovieRepeatModeOne;
self.productVideo.view.frame = self.productImage.frame;
self.productVideo.view.userInteractionEnabled = NO;
[;self.productVide.view addSubView:self.productImage]

[self.view addSubview:productVideo.view];

这就是您要实现的目标吗?

如果您打算在视频开始时隐藏图像或类似的东西,您可能无法使用 image.hidden = YES 和 image.hidden = NO。然后你将不得不求助于更改图像的 alpha 值,我听说这对某些人来说效果很好。

关于ios - 另一个 View 下的 MPMoviePlayerController View ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16595303/

相关文章:

ios - 读取存储在 Xcode 项目中的文件

uiview - 更新 UIImageView Swift 的位置

ios - 从顶部收缩 UIView

ios - 在 UICollectionView 中创建具有完全适合形状的 UIImageView 中的 UIImageView

iphone - ImageView 无法放大

ios - 返回可选值的类属性(字符串)(Swift)

iphone - 在 iOS 中添加多个 subview 的动画

ios - Swift - 如何显示跟踪事件的 MKPolyline

iphone - Nib 中的非全屏表格 View

ios - 将它用于 UIImageView 时 UIImage 失真