我正在为调用功能的画中画功能工作,要求获得窗口子视图
我使用此代码来获取它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。
已决定更改模式。