diff --git a/SwiftProject/SwiftProject.xcodeproj/project.pbxproj b/SwiftProject/SwiftProject.xcodeproj/project.pbxproj index d56512d..81db917 100644 --- a/SwiftProject/SwiftProject.xcodeproj/project.pbxproj +++ b/SwiftProject/SwiftProject.xcodeproj/project.pbxproj @@ -15,6 +15,8 @@ 006B61CF2BBA5D0A003FCB49 /* MembershipVCConfigureView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 006B61CE2BBA5D0A003FCB49 /* MembershipVCConfigureView.swift */; }; 006B61D12BBA5DB4003FCB49 /* MembershipProductView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 006B61D02BBA5DB4003FCB49 /* MembershipProductView.swift */; }; 006B61D32BBAA938003FCB49 /* StoreKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 006B61D22BBAA938003FCB49 /* StoreKit.framework */; }; + 006B61DC2BBCFAC4003FCB49 /* CustomSheetController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 006B61DB2BBCFAC4003FCB49 /* CustomSheetController.swift */; }; + 006B61DE2BBCFB45003FCB49 /* CustomSheetCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = 006B61DD2BBCFB45003FCB49 /* CustomSheetCell.swift */; }; 009661F82BAD6C7100FCA65F /* CCSpaceAlbumFilterPopView2.swift in Sources */ = {isa = PBXBuildFile; fileRef = 009661F72BAD6C7100FCA65F /* CCSpaceAlbumFilterPopView2.swift */; }; 009661FA2BAD876200FCA65F /* PhotosUI.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 009661F92BAD876200FCA65F /* PhotosUI.framework */; }; 009661FC2BADB20D00FCA65F /* CoreMotion.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 009661FB2BADB20D00FCA65F /* CoreMotion.framework */; }; @@ -114,6 +116,8 @@ 006B61CE2BBA5D0A003FCB49 /* MembershipVCConfigureView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MembershipVCConfigureView.swift; sourceTree = ""; }; 006B61D02BBA5DB4003FCB49 /* MembershipProductView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MembershipProductView.swift; sourceTree = ""; }; 006B61D22BBAA938003FCB49 /* StoreKit.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = StoreKit.framework; path = System/Library/Frameworks/StoreKit.framework; sourceTree = SDKROOT; }; + 006B61DB2BBCFAC4003FCB49 /* CustomSheetController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CustomSheetController.swift; sourceTree = ""; }; + 006B61DD2BBCFB45003FCB49 /* CustomSheetCell.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CustomSheetCell.swift; sourceTree = ""; }; 009661F72BAD6C7100FCA65F /* CCSpaceAlbumFilterPopView2.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CCSpaceAlbumFilterPopView2.swift; sourceTree = ""; }; 009661F92BAD876200FCA65F /* PhotosUI.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = PhotosUI.framework; path = System/Library/Frameworks/PhotosUI.framework; sourceTree = SDKROOT; }; 009661FB2BADB20D00FCA65F /* CoreMotion.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = CoreMotion.framework; path = System/Library/Frameworks/CoreMotion.framework; sourceTree = SDKROOT; }; @@ -255,6 +259,15 @@ path = UserInfo; sourceTree = ""; }; + 006B61DA2BBCFA54003FCB49 /* CustomSheetController */ = { + isa = PBXGroup; + children = ( + 006B61DB2BBCFAC4003FCB49 /* CustomSheetController.swift */, + 006B61DD2BBCFB45003FCB49 /* CustomSheetCell.swift */, + ); + path = CustomSheetController; + sourceTree = ""; + }; 0096624B2BB3BA0100FCA65F /* ExternalScreen */ = { isa = PBXGroup; children = ( @@ -533,6 +546,7 @@ AF2120A82B4E83B000400B7F /* View */ = { isa = PBXGroup; children = ( + 006B61DA2BBCFA54003FCB49 /* CustomSheetController */, 1E1EA28A2B9326DB00A5D5D2 /* CCSpatialDisplayTypeView */, 1EFAF0B42B8AF003002A1773 /* Album */, 1EFAF0BB2B8B1D55002A1773 /* MenuPop */, @@ -756,6 +770,7 @@ 005580782B9F1525004B9567 /* ZZHHelper.swift in Sources */, AF2120C32B4E95DA00400B7F /* NSObject+Add.swift in Sources */, 1EE5C5F72B8F973A00EDFC2F /* CCSpatialShootController.swift in Sources */, + 006B61DE2BBCFB45003FCB49 /* CustomSheetCell.swift in Sources */, 1EFB8C782B88E2F600C72119 /* UIColor+CCExtension.swift in Sources */, 00D33BF62B99A19900604A44 /* SpatialVideoConvertor.swift in Sources */, AF2120EE2B4EA34E00400B7F /* BaseTableViewPlainController.swift in Sources */, @@ -802,6 +817,7 @@ 006B61CF2BBA5D0A003FCB49 /* MembershipVCConfigureView.swift in Sources */, AF2120CE2B4E979500400B7F /* CCTextField.swift in Sources */, 1E1EA2882B9325D300A5D5D2 /* CCSpatialPhotoDisplayController.swift in Sources */, + 006B61DC2BBCFAC4003FCB49 /* CustomSheetController.swift in Sources */, ); runOnlyForDeploymentPostprocessing = 0; }; diff --git a/SwiftProject/SwiftProject.xcworkspace/xcuserdata/aaa.xcuserdatad/UserInterfaceState.xcuserstate b/SwiftProject/SwiftProject.xcworkspace/xcuserdata/aaa.xcuserdatad/UserInterfaceState.xcuserstate index d1915be..4fcb9d1 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.xcworkspace/xcuserdata/aaa.xcuserdatad/xcdebugger/Breakpoints_v2.xcbkptlist b/SwiftProject/SwiftProject.xcworkspace/xcuserdata/aaa.xcuserdatad/xcdebugger/Breakpoints_v2.xcbkptlist index 12a1f90..98b116c 100644 --- a/SwiftProject/SwiftProject.xcworkspace/xcuserdata/aaa.xcuserdatad/xcdebugger/Breakpoints_v2.xcbkptlist +++ b/SwiftProject/SwiftProject.xcworkspace/xcuserdata/aaa.xcuserdatad/xcdebugger/Breakpoints_v2.xcbkptlist @@ -649,5 +649,53 @@ + + + + + + + + + + diff --git a/SwiftProject/SwiftProject/Project/Controller/RecordingVideo/VRVideoTransformController.swift b/SwiftProject/SwiftProject/Project/Controller/RecordingVideo/VRVideoTransformController.swift index b0f8a21..dbab3fe 100644 --- a/SwiftProject/SwiftProject/Project/Controller/RecordingVideo/VRVideoTransformController.swift +++ b/SwiftProject/SwiftProject/Project/Controller/RecordingVideo/VRVideoTransformController.swift @@ -77,9 +77,9 @@ class VRVideoTransformController: BaseController { var videoWidth:Int = 1440 var videoHeight:Int = 1440 //分辨率 - var selectedPreset:AVOutputSettingsPreset = .mvhevc1440x1440 + var selectedPreset:AVOutputSettingsPreset = .preset1280x720 //bit - var selectedBitsPerPixel:VideoBitsPerPixel = .best + var selectedBitsPerPixel:VideoBitsPerPixel = .low //3D 格式 var selected3DFormat:Video3DFormat = .HSBS @@ -266,8 +266,8 @@ class VRVideoTransformController: BaseController { func setSpatialParametersListData() { let popData = [ (type:CCTransformParameterType.format3D,title:NSLocalizedString("3D 格式", comment: ""),name:"3D HSBS"), - (type:CCTransformParameterType.resolution,title:NSLocalizedString("分辨率", comment: "" ),name:NSLocalizedString("原始", comment: "")), - (type:CCTransformParameterType.bitRate,title:NSLocalizedString("比特率", comment: ""),name:NSLocalizedString("最佳", comment: "")), + (type:CCTransformParameterType.resolution,title:NSLocalizedString("分辨率", comment: "" ),name:"720p"), + (type:CCTransformParameterType.bitRate,title:NSLocalizedString("比特率", comment: ""),name:NSLocalizedString("低", comment: "")), (type:CCTransformParameterType.formatVideoEncoding,title:NSLocalizedString("视频编码格式", comment: ""),name:"H.265"), (type:CCTransformParameterType.horizontalDialogueAdjustment,title:NSLocalizedString("水平视差调整", comment: ""),name:"0")] @@ -453,42 +453,56 @@ class VRVideoTransformController: BaseController { 1080P 的分辨率为 1920x1080 像素。 4K 的分辨率为 3840x2160 像素。1 */ + showResolutionAlert() +// return +// let action1 = UIAlertAction(title: NSLocalizedString("原始", comment: "") , style: .default) {[weak self] (action:UIAlertAction) in +// self?.selectedPreset = .mvhevc1440x1440 +// self?.videoWidth = 1440 +// self?.videoHeight = 1440 +// self?.according3DFormatShowList(format: self!.selected3DFormat) +// } +// let action2 = UIAlertAction(title: "4K" , style: .default) {[weak self] (action:UIAlertAction) in +// self!.selectedPreset = .hevc3840x2160 +// self!.videoWidth = 3840 +// self!.videoHeight = 2160 +// self!.according3DFormatShowList(format: self!.selected3DFormat) +// } +// let action3 = UIAlertAction(title: "1080p" , style: .default) {[weak self] (action:UIAlertAction) in +// self!.selectedPreset = .hevc1920x1080 +// self!.videoWidth = 1920 +// self!.videoHeight = 1080 +// self!.according3DFormatShowList(format: self!.selected3DFormat) +// } +// let action4 = UIAlertAction(title: "720p" , style: .default) {[weak self] (action:UIAlertAction) in +// self!.selectedPreset = .preset1280x720 +// self!.videoWidth = 1280 +// self!.videoHeight = 720 +// self!.according3DFormatShowList(format: self!.selected3DFormat) +// } +// let cancelAction = UIAlertAction(title: NSLocalizedString("取消", comment: ""), style: .cancel, handler: nil) +// alert.addAction(action1) +// alert.addAction(action2) +// alert.addAction(action3) +// alert.addAction(action4) +// alert.addAction(cancelAction) +// self.present(alert, animated: true, completion: nil) +// +// + + + + + + + + + - let action1 = UIAlertAction(title: NSLocalizedString("原始", comment: "") , style: .default) {[weak self] (action:UIAlertAction) in - self?.selectedPreset = .mvhevc1440x1440 - self?.videoWidth = 1440 - self?.videoHeight = 1440 - self?.according3DFormatShowList(format: self!.selected3DFormat) - } - let action2 = UIAlertAction(title: "4K" , style: .default) {[weak self] (action:UIAlertAction) in - self!.selectedPreset = .hevc3840x2160 - self!.videoWidth = 3840 - self!.videoHeight = 2160 - self!.according3DFormatShowList(format: self!.selected3DFormat) - } - let action3 = UIAlertAction(title: "1080p" , style: .default) {[weak self] (action:UIAlertAction) in - self!.selectedPreset = .hevc1920x1080 - self!.videoWidth = 1920 - self!.videoHeight = 1080 - self!.according3DFormatShowList(format: self!.selected3DFormat) - } - let action4 = UIAlertAction(title: "720p" , style: .default) {[weak self] (action:UIAlertAction) in - self!.selectedPreset = .preset1280x720 - self!.videoWidth = 1280 - self!.videoHeight = 720 - self!.according3DFormatShowList(format: self!.selected3DFormat) - } - let cancelAction = UIAlertAction(title: NSLocalizedString("取消", comment: ""), style: .cancel, handler: nil) - alert.addAction(action1) - alert.addAction(action2) - alert.addAction(action3) - alert.addAction(action4) - alert.addAction(cancelAction) - self.present(alert, animated: true, completion: nil) break case .bitRate: + showBitRateAlert() print("比特率") /* 最佳(最佳比特率,与原视频一致) @@ -497,29 +511,29 @@ class VRVideoTransformController: BaseController { 低(约为原视频25%) */ - let action1 = UIAlertAction(title: NSLocalizedString("最佳", comment: "") , style: .default) {[weak self] (action:UIAlertAction) in - self!.selectedBitsPerPixel = .best - self!.according3DFormatShowList(format: self!.selected3DFormat) - } - let action2 = UIAlertAction(title: NSLocalizedString("高", comment: "") , style: .default) {[weak self] (action:UIAlertAction) in - self!.selectedBitsPerPixel = .high - self!.according3DFormatShowList(format: self!.selected3DFormat) - } - let action3 = UIAlertAction(title: NSLocalizedString("中", comment: "") , style: .default) {[weak self] (action:UIAlertAction) in - self!.selectedBitsPerPixel = .medium - self!.according3DFormatShowList(format: self!.selected3DFormat) - } - let action4 = UIAlertAction(title: NSLocalizedString("低", comment: "") , style: .default) {[weak self] (action:UIAlertAction) in - self!.selectedBitsPerPixel = .low - self!.according3DFormatShowList(format: self!.selected3DFormat) - } - let cancelAction = UIAlertAction(title: NSLocalizedString("取消", comment: ""), style: .cancel, handler: nil) - alert.addAction(action1) - alert.addAction(action2) - alert.addAction(action3) - alert.addAction(action4) - alert.addAction(cancelAction) - self.present(alert, animated: true, completion: nil) +// let action1 = UIAlertAction(title: NSLocalizedString("最佳", comment: "") , style: .default) {[weak self] (action:UIAlertAction) in +// self!.selectedBitsPerPixel = .best +// self!.according3DFormatShowList(format: self!.selected3DFormat) +// } +// let action2 = UIAlertAction(title: NSLocalizedString("高", comment: "") , style: .default) {[weak self] (action:UIAlertAction) in +// self!.selectedBitsPerPixel = .high +// self!.according3DFormatShowList(format: self!.selected3DFormat) +// } +// let action3 = UIAlertAction(title: NSLocalizedString("中", comment: "") , style: .default) {[weak self] (action:UIAlertAction) in +// self!.selectedBitsPerPixel = .medium +// self!.according3DFormatShowList(format: self!.selected3DFormat) +// } +// let action4 = UIAlertAction(title: NSLocalizedString("低", comment: "") , style: .default) {[weak self] (action:UIAlertAction) in +// self!.selectedBitsPerPixel = .low +// self!.according3DFormatShowList(format: self!.selected3DFormat) +// } +// let cancelAction = UIAlertAction(title: NSLocalizedString("取消", comment: ""), style: .cancel, handler: nil) +// alert.addAction(action1) +// alert.addAction(action2) +// alert.addAction(action3) +// alert.addAction(action4) +// alert.addAction(cancelAction) +// self.present(alert, animated: true, completion: nil) break @@ -559,6 +573,101 @@ class VRVideoTransformController: BaseController { } } + + //显示分辨率选项 + func showResolutionAlert() { + let alertVC = CustomSheetController() + let dataSource = [ + ["imgName":"vip_Diamond","text":NSLocalizedString("原始", comment: "")], + ["imgName":"vip_Diamond","text":"4K"], + ["imgName":"vip_Diamond","text":"1080p"], + ["text":"720p"] + ] + alertVC.setData(data: dataSource) {[weak self] text in + if (text == "720p"){ + self!.selectedPreset = .preset1280x720 + self!.videoWidth = 1280 + self!.videoHeight = 720 + self!.according3DFormatShowList(format: self!.selected3DFormat) + } + else { + if !UserInfo.sharedInstance.isMemberShip { + //不是就跳转引导购买 + let vc:MembershipVC = MembershipVC() + let nav = UINavigationController(rootViewController: vc) + nav.modalTransitionStyle = UIModalTransitionStyle.coverVertical + nav.modalPresentationStyle = .fullScreen + self?.present(nav, animated: true) + } + else { + if (text == NSLocalizedString("原始", comment: "")) { + self?.selectedPreset = .mvhevc1440x1440 + self?.videoWidth = 1440 + self?.videoHeight = 1440 + self?.according3DFormatShowList(format: self!.selected3DFormat) + } + else if (text == "4K") { + self!.selectedPreset = .hevc3840x2160 + self!.videoWidth = 3840 + self!.videoHeight = 2160 + self!.according3DFormatShowList(format: self!.selected3DFormat) + } + else if (text == "1080p"){ + self!.selectedPreset = .hevc1920x1080 + self!.videoWidth = 1920 + self!.videoHeight = 1080 + self!.according3DFormatShowList(format: self!.selected3DFormat) + } + } + } + + + } + + alertVC.presentController(vc: self) + } + + //显示比特率 + func showBitRateAlert() { + let alertVC = CustomSheetController() + let dataSource = [ + ["imgName":"vip_Diamond","text":NSLocalizedString("最佳", comment: "")], + ["imgName":"vip_Diamond","text":NSLocalizedString("高", comment: "")], + ["imgName":"vip_Diamond","text":NSLocalizedString("中", comment: "")], + ["text":NSLocalizedString("低", comment: "")] + ] + alertVC.setData(data: dataSource) {[weak self] text in + if (text == NSLocalizedString("低", comment: "")) { + self!.selectedBitsPerPixel = .low + self!.according3DFormatShowList(format: self!.selected3DFormat) + } + else { + if !UserInfo.sharedInstance.isMemberShip {//判断是否为vip + //不是就跳转引导购买 + let vc:MembershipVC = MembershipVC() + let nav = UINavigationController(rootViewController: vc) + nav.modalTransitionStyle = UIModalTransitionStyle.coverVertical + nav.modalPresentationStyle = .fullScreen + self?.present(nav, animated: true) + } + else { + if (text == NSLocalizedString("最佳", comment: "")) { + self!.selectedBitsPerPixel = .best + self!.according3DFormatShowList(format: self!.selected3DFormat) + } + else if (text == NSLocalizedString("高", comment: "")) { + self!.selectedBitsPerPixel = .high + self!.according3DFormatShowList(format: self!.selected3DFormat) + } + else if (text == NSLocalizedString("中", comment: "")) { + self!.selectedBitsPerPixel = .medium + self!.according3DFormatShowList(format: self!.selected3DFormat) + } + } + } + } + alertVC.presentController(vc: self) + } } diff --git a/SwiftProject/SwiftProject/Project/View/CCSpatialPlayView.swift b/SwiftProject/SwiftProject/Project/View/CCSpatialPlayView.swift index badd286..1f1e51d 100644 --- a/SwiftProject/SwiftProject/Project/View/CCSpatialPlayView.swift +++ b/SwiftProject/SwiftProject/Project/View/CCSpatialPlayView.swift @@ -123,12 +123,13 @@ class CCSpatialPlayView: UIView,UITableViewDelegate,UITableViewDataSource{ cell.mVIPImgView?.frame = .zero } else { - cell.mVIPImgView?.frame = CGRect(x: 0, y: 0, width: 30, height: 30) + let wh:CGFloat = 26.0 + cell.mVIPImgView?.frame = CGRect(x: 0, y: 0, width: wh, height: wh) cell.mVIPImgView?.centerY = CCSpatialPlayCell1H * 0.5 cell.mVIPImgView?.left = 16 cell.mLabel1!.centerY = CCSpatialPlayCell1H * 0.5 - cell.mLabel1!.left = 16 + 30 + 5 + cell.mLabel1!.left = 16 + wh + 8 } } return cell @@ -179,7 +180,7 @@ class CCSpatialPlayCell1: UITableViewCell { mVIPImgView = UIImageView() self.contentView.addSubview(mVIPImgView!) mVIPImgView?.frame = .zero - mVIPImgView?.image = UIImage(named: "logo") + mVIPImgView?.image = UIImage(named: "vip_Diamond") mLabel1 = UILabel() mLabel1!.bounds = CGRect(x: 0, y: 0, width: 100, height: 0) diff --git a/SwiftProject/SwiftProject/Project/View/CustomSheetController/CustomSheetCell.swift b/SwiftProject/SwiftProject/Project/View/CustomSheetController/CustomSheetCell.swift new file mode 100644 index 0000000..0977ec8 --- /dev/null +++ b/SwiftProject/SwiftProject/Project/View/CustomSheetController/CustomSheetCell.swift @@ -0,0 +1,74 @@ +// +// CustomSheetCell.swift +// SwiftProject +// +// Created by aaa on 2024/4/3. +// + +import Foundation +import UIKit +class CustomSheetCell: UITableViewCell { + + lazy var rightImgView:UIImageView? = { + let imgView = UIImageView() + return imgView + }() + + lazy var leftLabel:UILabel? = { + let label = UILabel() + label.textColor = .white + label.font = UIFont.systemFont(ofSize: 16) + label.textAlignment = .center + return label + }() + + let wh:CGFloat = 25 + + override init(style: UITableViewCell.CellStyle, reuseIdentifier: String?) { + super.init(style: style, reuseIdentifier: reuseIdentifier) + self.backgroundColor = .clear + self.contentView.addSubview(rightImgView!) + self.contentView.addSubview(leftLabel!) + + + rightImgView?.snp.makeConstraints({ make in + make.width.equalTo(wh) + make.height.equalTo(wh) + make.centerY.equalToSuperview() + }) + + leftLabel?.snp.makeConstraints({ make in + make.top.bottom.equalTo(0) + make.left.equalTo(rightImgView!.snp.right).offset(8) + make.centerX.equalToSuperview() + make.width.equalTo(60) + }) + + self.contentView.backgroundColor = UIColor(r: 20, g: 20, b: 20, a: 1) + } + + required init?(coder: NSCoder) { + fatalError("init(coder:) has not been implemented") + } + + func setCData(_ data:[String:String]) { + rightImgView?.image = nil + leftLabel?.text = nil + if !UserInfo.sharedInstance.isMemberShip { + let imgName = data["imgName"] + if let im = imgName { + rightImgView?.image = UIImage(named: im) + + rightImgView?.isHidden = false + } + else { + + rightImgView?.isHidden = true + } + } + + + let text = data["text"] + leftLabel?.text = text + } +} diff --git a/SwiftProject/SwiftProject/Project/View/CustomSheetController/CustomSheetController.swift b/SwiftProject/SwiftProject/Project/View/CustomSheetController/CustomSheetController.swift new file mode 100644 index 0000000..d23727a --- /dev/null +++ b/SwiftProject/SwiftProject/Project/View/CustomSheetController/CustomSheetController.swift @@ -0,0 +1,165 @@ +// +// CustomSheetController.swift +// SwiftProject +// +// Created by aaa on 2024/4/3. +// + +import Foundation +import UIKit + +typealias CustomSheetControllerSelectCallback = (String?)->Void +class CustomSheetController: UIViewController,UITableViewDataSource,UITableViewDelegate { + lazy var tableView:UITableView? = { + let table = UITableView(frame: .zero, style: .insetGrouped) + table.delegate = self + table.dataSource = self + table.isScrollEnabled = false + table.backgroundColor = .clear + table.register(CustomSheetCell.classForCoder(), forCellReuseIdentifier: kCellIdentifier) + return table + }() + var dataSource:[[String:String]] = [] + let kCellIdentifier = "kkCustomSheetCell" + var selectCallback:CustomSheetControllerSelectCallback? + var selectText = "" + deinit { + print("custom sheet controller.....deinit") + } + + override func viewDidLoad() { + super.viewDidLoad() + self.view.backgroundColor = UIColor(r: 20, g: 20, b: 20, a: 0.2) + + let fview = UIView() + fview.backgroundColor = .clear + self.view.addSubview(fview) + fview.snp.makeConstraints { make in + make.left.top.right.bottom.equalToSuperview() + } + let tap = UITapGestureRecognizer(target: self, action: #selector(tapGuester(sender: ))) + fview.addGestureRecognizer(tap) + + self.view.addSubview(tableView!) + tableView?.snp.makeConstraints({ make in + make.left.right.equalToSuperview() +// make.height.equalTo(0) + make.height.equalTo(self.getHeight()) + make.bottom.equalToSuperview().offset(self.getHeight()) + }) + + + self.view.layoutIfNeeded() + + } + + override func viewWillAppear(_ animated: Bool) { + super.viewWillAppear(animated) + UIView.animate(withDuration: 0.25) {[weak self] in + self?.tableView?.snp.updateConstraints({ make in + make.bottom.equalToSuperview().offset(0) + }) + self?.view.layoutIfNeeded() + } completion: { finish in + + } + + tableView?.reloadData() + } + + func setData(data:[[String:String]],callback:CustomSheetControllerSelectCallback?) { + dataSource.removeAll() + dataSource.append(contentsOf: data) + + selectCallback = callback + } + + func getHeight() -> CGFloat { + var height:CGFloat = 0.0 + height = CGFloat(dataSource.count) * 56 + height = height + 56 + 10 + 70 + return height + } + + func presentController(vc:UIViewController) { + vc.modalPresentationStyle = UIModalPresentationStyle.popover +// vc.modalTransitionStyle = UIModalTransitionStyle.coverVertical + vc.present(self, animated: false) + } + + @objc func tapGuester(sender:UITapGestureRecognizer){ + self.dismissVC() + } + + func dismissVC() { + UIView.animate(withDuration: 0.25) {[weak self] in + if let weakSelf = self { + weakSelf.view.backgroundColor = UIColor(r: 20, g: 20, b: 20, a: 0) + if let tb = weakSelf.tableView { + tb.snp.updateConstraints{ make in + make.bottom.equalToSuperview().offset(tb.bounds.height) + } + } + } + self?.view.layoutIfNeeded() + + } completion: {[weak self] result in + self?.dismiss(animated: false) + if let sc = self?.selectCallback { + sc(self?.selectText) + } + } + } + + + //MARK: - UITableViewDataSource,UITableViewDelegate + func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int { + if section == 0 { + return dataSource.count + } + return 1 + + } + + func numberOfSections(in tableView: UITableView) -> Int { + return 2 + } + + func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell { + let cell = tableView.dequeueReusableCell(withIdentifier: kCellIdentifier, for: indexPath) as! CustomSheetCell + if indexPath.section == 0 { + let data = dataSource[indexPath.row] + cell.setCData(data) + } + else { + cell.setCData(["text":NSLocalizedString("取消", comment: "")]) + } + + return cell + } + + func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) { + if indexPath.section == 0 {//非取消按钮 + let data = dataSource[indexPath.row] + selectText = data["text"] ?? "" + } + + self.dismissVC() + } + + func tableView(_ tableView: UITableView, heightForHeaderInSection section: Int) -> CGFloat { + return 8.0 + } + + func tableView(_ tableView: UITableView, heightForFooterInSection section: Int) -> CGFloat { + return 0.1 + } + + func tableView(_ tableView: UITableView, viewForFooterInSection section: Int) -> UIView? { + return UIView() + } + + func tableView(_ tableView: UITableView, heightForRowAt indexPath: IndexPath) -> CGFloat { + return 56 + } +} diff --git a/SwiftProject/SwiftProject/zh-Hans.lproj/Localizable.strings b/SwiftProject/SwiftProject/zh-Hans.lproj/Localizable.strings index 2b57b6d..a587681 100644 --- a/SwiftProject/SwiftProject/zh-Hans.lproj/Localizable.strings +++ b/SwiftProject/SwiftProject/zh-Hans.lproj/Localizable.strings @@ -90,6 +90,6 @@ "Free Trail 3 Days" = "Free Trail 3 Days"; "subscribDesc" = "免费试用3天,试用结束后,按照图示费用进行续费,您可以随时在Tunes Store中取消订阅.若已订阅过或已付费成功却未显示,可使用相同AppleID恢复会员.确认购买后将从iTunes账户扣款,自动续订会在到期前24小时内扣款,可前往AppleID管理页面关闭订阅."; "用户协议" = "用户协议"; -"userSiteUrl" = "https://www.wolai.com/9BZr3sEbpbXJEUorHEyAoP"; +"userSiteUrl" = "https://cyan-camel-1d1v3n.mysxl.cn/"; "Membership activated" = "Membership activated"; "restorevip" = "恢复购买";