我正在为调用功能开发画中画输出功能,其中需要获取窗口子视图
我用这段代码来获取它transitionView = AppDelegate.shared.window?.subviews[1] ?? self.view
它在 iOS 13 版本上运行的更少 但是理智的代码在iOS 13中崩溃
了这是我的完整功能
func showPictureInPictureMode(){
transitionView = AppDelegate.shared.window?.subviews[1] ?? self.view
transitionView?.frame = CGRect(x: screenWidth - width - 13, y: 80, width: width, height: height)
transitionView?.layer.cornerRadius = 10
transitionView?.clipsToBounds = true
transitionView?.addGestureRecognizer(transitionPanGesture)
transitionView?.layer.borderColor = #colorLiteral(red: 0.07843137255, green: 0.07843137255, blue: 0.07843137255, alpha: 1)
transitionView?.borderWidth = 1
self.view.layer.borderColor = #colorLiteral(red: 0.07843137255, green: 0.07843137255, blue: 0.07843137255, alpha: 1)
self.view.layer.borderWidth = 1
self.view.layer.cornerRadius = 10
self.view.clipsToBounds = false
self.view.layoutIfNeeded()
self.isPictureInPicture = true
self.toolbar.isHidden = true
self.pictureModeButton.isHidden = true
self.timeLabel.isHidden = true
self.opponentsCollectionView.reloadData()
NotificationCenter.default.post(name: .reloadButtonState, object: nil)
}
有人可以帮助解决问题吗?
提前致谢
得到解决方案 简单地说,我将UIViewController演示文稿样式.defualt
更改为.overFullScreen
喜欢这个:
pipVC.ModalPresentationStyle = . overFullScreen
原因是,在以默认样式显示屏幕时没有获得UILayoutContainerView。
它决心改变模式。