diff --git a/SwiftProject/SwiftProject.xcworkspace/xcuserdata/aaa.xcuserdatad/UserInterfaceState.xcuserstate b/SwiftProject/SwiftProject.xcworkspace/xcuserdata/aaa.xcuserdatad/UserInterfaceState.xcuserstate index 4f98333..5242ed3 100644 Binary files a/SwiftProject/SwiftProject.xcworkspace/xcuserdata/aaa.xcuserdatad/UserInterfaceState.xcuserstate and b/SwiftProject/SwiftProject.xcworkspace/xcuserdata/aaa.xcuserdatad/UserInterfaceState.xcuserstate differ diff --git a/SwiftProject/SwiftProject/Project/Controller/RecordingVideo/CCSpatialPhotoDisplayController/CCSpatialPhotoDisplayController.swift b/SwiftProject/SwiftProject/Project/Controller/RecordingVideo/CCSpatialPhotoDisplayController/CCSpatialPhotoDisplayController.swift index b4c9dd4..001a0f1 100644 --- a/SwiftProject/SwiftProject/Project/Controller/RecordingVideo/CCSpatialPhotoDisplayController/CCSpatialPhotoDisplayController.swift +++ b/SwiftProject/SwiftProject/Project/Controller/RecordingVideo/CCSpatialPhotoDisplayController/CCSpatialPhotoDisplayController.swift @@ -123,7 +123,7 @@ class CCSpatialPhotoDisplayController: BaseController { let imageView = UIImageView() imageView.frame = CGRect.init(x: 0, y: 250, width: self.view.frame.size.width, height: 240) imageView.contentMode = .scaleAspectFit - imageView.backgroundColor = UIColor.clear + imageView.backgroundColor = UIColor.black imageView.isUserInteractionEnabled = true return imageView @@ -167,12 +167,57 @@ class CCSpatialPhotoDisplayController: BaseController { deinit { print("spatioal photo display deinit...\(self)") NotificationCenter.default.removeObserver(self) + // 停止监听设备方向变化 + UIDevice.current.endGeneratingDeviceOrientationNotifications() } + // 开始监听设备方向变化 + func listingScreenOrientatinChange() { + UIDevice.current.beginGeneratingDeviceOrientationNotifications() + // 添加监听器 + NotificationCenter.default.addObserver(self, selector: #selector(screenOrientationRotate), name: UIDevice.orientationDidChangeNotification, object: nil) + } + + @objc func screenOrientationRotate() { + let orientation = UIDevice.current.orientation + switch orientation { + case .portrait , .portraitUpsideDown: + print("Portrait") + navtionBar?.snp.updateConstraints { make in + make.top.equalToSuperview().offset(0) + } + mImgView.snp.updateConstraints { make in + make.height.equalTo(KScreenWidth) + } + self.view.layoutIfNeeded() + self.navtionBar?.isHidden = false + mTopImgView.isHidden = false + break + case .landscapeLeft , .landscapeRight: + print("Landscape ...") + navtionBar?.snp.updateConstraints { make in + make.top.equalToSuperview().offset(-KStatusBarHeight * 0.5) + } + mImgView.snp.updateConstraints { make in + make.height.equalTo(240) + } + self.view.layoutIfNeeded() + self.navtionBar?.isHidden = true + mTopImgView.isHidden = true + break + default: + print("Other") + } + } + override func viewDidLoad() { super.viewDidLoad() + KAppDelegate?.allowRotation = true + listingScreenOrientatinChange() + updateNavgationBarColorImgMakeConstraint() + ZZHHelper.setNowTimeToUserDefaultWithKey(kNowTimeToUserDefaultKey_PhotoDisplayController) print("spatioal photo viewdidload...\(self)") // return @@ -210,12 +255,32 @@ class CCSpatialPhotoDisplayController: BaseController { self.setNavgationBarLine(color: .clear) self.view.addSubview(mTopImgView) + mTopImgView.snp.makeConstraints { make in + make.left.right.top.equalToSuperview() + make.height.equalTo(236) + } self.view.bringSubviewToFront(self.navtionBar!) // navtionBar?.addSubview(backButton) navtionBar?.addSubview(transformButton) + transformButton.snp.makeConstraints { make in + make.width.equalTo(56) + make.height.equalTo(36) + make.right.equalToSuperview().offset(-14) + make.centerY.equalToSuperview().offset(StatuBar_Height*0.5) + } navtionBar?.addSubview(mTopCenterTypeButton) + mTopCenterTypeButton.snp.makeConstraints { make in + make.height.equalTo(36) + make.width.equalTo(SCREEN_Width * 0.4 + 20) + make.centerX.equalToSuperview() + make.centerY.equalToSuperview().offset(StatuBar_Height*0.5) + } self.view.addSubview(mImgView) - + mImgView.snp.makeConstraints { make in + make.left.right.equalToSuperview() + make.height.equalTo(240) + make.centerY.equalToSuperview() + } self.view.addSubview(tipsButton) checkAirPlayStatus() @@ -308,10 +373,29 @@ class CCSpatialPhotoDisplayController: BaseController { //左边按钮 }else if sender.tag == 201 { //右边按钮 - let transVC = VRPhotoTransformController() - transVC.sourceImageData = photoOriginalData - transVC.imageAsset = imageAsset - self.navigationController?.pushViewController(transVC, animated: true) + let orientation = UIDevice.current.orientation + if orientation == .landscapeLeft || orientation == .landscapeRight { + KAppDelegate?.allowRotation = false + self.setNeedsUpdateOfSupportedInterfaceOrientations() + DispatchQueue.main.asyncAfter(deadline: .now()+0.25, execute: {[weak self] in + //右边按钮 + let transVC = VRPhotoTransformController() + transVC.sourceImageData = self?.photoOriginalData + transVC.imageAsset = self?.imageAsset + self?.navigationController?.pushViewController(transVC, animated: true) + }) + } + else { + let transVC = VRPhotoTransformController() + transVC.sourceImageData = photoOriginalData + transVC.imageAsset = imageAsset + self.navigationController?.pushViewController(transVC, animated: true) + } + + + + + Analytics.logEvent("preview_trans_click", parameters: nil) }else if sender.tag == 202 { //中间按钮