图片预览页面的旋转功能,待对应的缩放、瞳距加上后,再进一步处理,相当于处理了一半

This commit is contained in:
bluesea 2024-04-26 14:13:53 +08:00
parent f1b0ce48d8
commit 606dc13535
2 changed files with 90 additions and 6 deletions

View File

@ -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 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 {
//