图片预览页面的旋转功能,待对应的缩放、瞳距加上后,再进一步处理,相当于处理了一半
This commit is contained in:
parent
f1b0ce48d8
commit
606dc13535
Binary file not shown.
@ -123,7 +123,7 @@ class CCSpatialPhotoDisplayController: BaseController {
|
|||||||
let imageView = UIImageView()
|
let imageView = UIImageView()
|
||||||
imageView.frame = CGRect.init(x: 0, y: 250, width: self.view.frame.size.width, height: 240)
|
imageView.frame = CGRect.init(x: 0, y: 250, width: self.view.frame.size.width, height: 240)
|
||||||
imageView.contentMode = .scaleAspectFit
|
imageView.contentMode = .scaleAspectFit
|
||||||
imageView.backgroundColor = UIColor.clear
|
imageView.backgroundColor = UIColor.black
|
||||||
|
|
||||||
imageView.isUserInteractionEnabled = true
|
imageView.isUserInteractionEnabled = true
|
||||||
return imageView
|
return imageView
|
||||||
@ -167,12 +167,57 @@ class CCSpatialPhotoDisplayController: BaseController {
|
|||||||
deinit {
|
deinit {
|
||||||
print("spatioal photo display deinit...\(self)")
|
print("spatioal photo display deinit...\(self)")
|
||||||
NotificationCenter.default.removeObserver(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() {
|
override func viewDidLoad() {
|
||||||
super.viewDidLoad()
|
super.viewDidLoad()
|
||||||
|
KAppDelegate?.allowRotation = true
|
||||||
|
listingScreenOrientatinChange()
|
||||||
|
updateNavgationBarColorImgMakeConstraint()
|
||||||
|
|
||||||
ZZHHelper.setNowTimeToUserDefaultWithKey(kNowTimeToUserDefaultKey_PhotoDisplayController)
|
ZZHHelper.setNowTimeToUserDefaultWithKey(kNowTimeToUserDefaultKey_PhotoDisplayController)
|
||||||
print("spatioal photo viewdidload...\(self)")
|
print("spatioal photo viewdidload...\(self)")
|
||||||
// return
|
// return
|
||||||
@ -210,12 +255,32 @@ class CCSpatialPhotoDisplayController: BaseController {
|
|||||||
self.setNavgationBarLine(color: .clear)
|
self.setNavgationBarLine(color: .clear)
|
||||||
|
|
||||||
self.view.addSubview(mTopImgView)
|
self.view.addSubview(mTopImgView)
|
||||||
|
mTopImgView.snp.makeConstraints { make in
|
||||||
|
make.left.right.top.equalToSuperview()
|
||||||
|
make.height.equalTo(236)
|
||||||
|
}
|
||||||
self.view.bringSubviewToFront(self.navtionBar!)
|
self.view.bringSubviewToFront(self.navtionBar!)
|
||||||
// navtionBar?.addSubview(backButton)
|
// navtionBar?.addSubview(backButton)
|
||||||
navtionBar?.addSubview(transformButton)
|
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)
|
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)
|
self.view.addSubview(mImgView)
|
||||||
|
mImgView.snp.makeConstraints { make in
|
||||||
|
make.left.right.equalToSuperview()
|
||||||
|
make.height.equalTo(240)
|
||||||
|
make.centerY.equalToSuperview()
|
||||||
|
}
|
||||||
self.view.addSubview(tipsButton)
|
self.view.addSubview(tipsButton)
|
||||||
checkAirPlayStatus()
|
checkAirPlayStatus()
|
||||||
|
|
||||||
@ -308,10 +373,29 @@ class CCSpatialPhotoDisplayController: BaseController {
|
|||||||
//左边按钮
|
//左边按钮
|
||||||
}else if sender.tag == 201 {
|
}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()
|
let transVC = VRPhotoTransformController()
|
||||||
transVC.sourceImageData = photoOriginalData
|
transVC.sourceImageData = photoOriginalData
|
||||||
transVC.imageAsset = imageAsset
|
transVC.imageAsset = imageAsset
|
||||||
self.navigationController?.pushViewController(transVC, animated: true)
|
self.navigationController?.pushViewController(transVC, animated: true)
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
Analytics.logEvent("preview_trans_click", parameters: nil)
|
Analytics.logEvent("preview_trans_click", parameters: nil)
|
||||||
}else if sender.tag == 202 {
|
}else if sender.tag == 202 {
|
||||||
//中间按钮
|
//中间按钮
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user