gpt4 book ai didi

ios - 如何将 Storyboard 中的 UIButton 添加到 iOS 中 AVPlayer 的顶部?

转载 作者:行者123 更新时间:2023-12-01 19:56:53 24 4
gpt4 key购买 nike

我正在我的应用程序中执行类似于 Uber 的视频启动。我在 Storyboard底部的 Storyboard中添加了两个按钮, Storyboard中的间距相等。现在我正在添加 AVPlayer 来播放 NSBundle 中的视频。在运行应用程序时,视频正在播放,但我在底部看不到我的按钮。为什么会这样?请建议..

   - (void)createVideoPlayer {

NSString *filePath = [[NSBundle mainBundle] pathForResource:@"welcome_video" ofType:@"mp4"];
NSURL *url = [NSURL fileURLWithPath:filePath];

AVPlayerItem *playerItem = [AVPlayerItem playerItemWithURL:url];

self.player = [AVPlayer playerWithPlayerItem:playerItem];
self.player.volume = PLAYER_VOLUME;

AVPlayerLayer *playerLayer = [AVPlayerLayer playerLayerWithPlayer:self.player];
playerLayer.videoGravity = UIViewContentModeScaleToFill;
playerLayer.frame = self.playerView.layer.bounds;
[self.playerView.layer addSublayer:playerLayer];

[self.player play];

[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(moviePlayDidEnd:) name:AVPlayerItemDidPlayToEndTimeNotification object:self.player.currentItem];
}

- (void)moviePlayDidEnd:(NSNotification*)notification{

AVPlayerItem *item = [notification object];
[item seekToTime:kCMTimeZero];
[self.player play];
}

Storyboard中按钮的屏幕截图:
enter image description here

模拟器中的输出:

enter image description here

您可以看到缺少按钮和 注意:这些按钮的约束是正确的,我可以在每次预览中看到它们...

最佳答案

您需要调用bringSubviewToFront带上您的Button AVPlayer 上的导出正面和可见添加后AVPlyer你认为的实例。

[self.view bringSubviewToFront:buttonOutlet];

关于ios - 如何将 Storyboard 中的 UIButton 添加到 iOS 中 AVPlayer 的顶部?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42017610/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com