// // CCHomeController.swift // SwiftProject // // Created by soldoros on 2024/1/10. // import CoreImage import Foundation //import Observation import VideoToolbox import AVFoundation import MetalKit //import Cocoa import SwiftUI import CoreImage import Foundation //import Observation import VideoToolbox import AVKit import CoreMedia import LLCycleScrollView import TZImagePickerController import MessageUI import SVProgressHUD import Firebase import AdSupport class CCHomeController: BaseController, LLCycleScrollViewDelegate,MFMailComposeViewControllerDelegate { var heroAsset:AVAsset? var mTopImgView:UIImageView? var mBottomImgView:UIImageView? var mTopCenterBtn:UIButton? var cycleScrollView:LLCycleScrollView? var mCenLab1:UILabel? var mCenLab2:UILabel? var mBottomView:UIView? var mBottomBtn1:UIButton? var mBottomBtn2:UIButton? var mBottomBtn3:UIButton? var mineView:CCMineView? // var mTopView:UIView? var mBackView:UIView? var selectedAssets:[Any] = [] var maxImages:NSInteger = 10 let kNowTimeToUserDefaultKey_Home:String = "kNowTimeToUserDefaultKey_Home" lazy var spaceAlbumPopView: CCSpaceAlbumFilterPopView2 = { let view = CCSpaceAlbumFilterPopView2.init(frame: CGRectMake(0, 0, KScreenWidth, KScreenHeight)) return view }() override func viewWillAppear(_ animated: Bool) { super.viewWillAppear(animated) self.navigationController?.tabBarController!.tabBar.isHidden = true; self.navigationController?.tabBarController!.tabBar.isTranslucent = true; self.setNavgationBarColor(color: UIColor.clear) self.checkAirPlayStatus() } override func viewDidLoad() { super.viewDidLoad() uploadAppInfo() ZZHHelper.setNowTimeToUserDefaultWithKey(kNowTimeToUserDefaultKey_Home) self.view.backgroundColor = UIColor.black self.navLine?.isHidden = true // 监听 AirPlay 设备的连接状态 NotificationCenter.default.addObserver(self, selector: #selector(airPlayStatusDidChange(_:)), name: AVAudioSession.routeChangeNotification, object: nil) //393*236 mTopImgView = UIImageView(frame: CGRect(x: 0, y: 0, width: SCREEN_Width, height: SCREEN_Height * 236/393)) view.addSubview(mTopImgView!) mTopImgView?.image = UIImage.init(named: "BG_Top") self.view.bringSubviewToFront(self.navtionBar!) //393*240 mBottomImgView = UIImageView(frame: CGRect(x: 0, y: 0, width: SCREEN_Width, height: SCREEN_Height * 240/393)) mBottomImgView!.bottom = SCREEN_Height view.addSubview(mBottomImgView!) mBottomImgView?.image = UIImage.init(named: "BG_Bottom_Light") //76*56 leftBtn1 = UIButton.init(type: UIButton.ButtonType.custom) navtionBar?.addSubview(leftBtn1!) leftBtn1?.tag = 11 leftBtn1?.isSelected = false leftBtn1?.addTarget(self, action: #selector(navgationButtonClick2(sender:)), for: UIControl.Event.touchUpInside) let img:UIImage = UIImage.init(named: "Icon_Menu" as String)! leftBtn1?.setImage(img, for: UIControl.State.normal) leftBtn1?.frame = CGRect(x: 5, y: 10, width: 76, height: 56) leftBtn1!.centerY = StatuBar_Height + NavBar_Height * 0.5 //76*56 rightBtn1 = UIButton.init(type: UIButton.ButtonType.custom) navtionBar?.addSubview(rightBtn1!) rightBtn1?.tag = 10 rightBtn1?.isSelected = false rightBtn1?.addTarget(self, action: #selector(navgationButtonClick2(sender:)), for: UIControl.Event.touchUpInside) let img2:UIImage = UIImage.init(named: "vip_Diamond" as String)! rightBtn1?.setImage(img2, for: UIControl.State.normal) rightBtn1?.frame = CGRect(x: 2, y: 10, width: 76, height: 56) rightBtn1!.centerY = StatuBar_Height + NavBar_Height * 0.5 rightBtn1!.right = SCREEN_Width //173*36 mTopCenterBtn = UIButton.init(type: UIButton.ButtonType.custom) navtionBar?.addSubview(mTopCenterBtn!) mTopCenterBtn!.backgroundColor = UIColor.hexStringToColor(hexString: "#060507") mTopCenterBtn?.tag = 12 mTopCenterBtn?.isSelected = false mTopCenterBtn?.addTarget(self, action: #selector(navgationButtonClick2(sender:)), for: UIControl.Event.touchUpInside) mTopCenterBtn?.frame = CGRect(x: 2, y: 10, width: SCREEN_Width * 0.4, height: 36) mTopCenterBtn!.centerY = StatuBar_Height + NavBar_Height * 0.5 mTopCenterBtn!.centerX = SCREEN_Width * 0.5 mTopCenterBtn!.clipsToBounds = true mTopCenterBtn!.layer.cornerRadius = mTopCenterBtn!.height * 0.5 mTopCenterBtn!.layer.borderWidth = 0.5 mTopCenterBtn!.layer.borderColor = UIColor.white.cgColor mTopCenterBtn!.setTitle(NSLocalizedString("未连接VR设备", comment: ""), for: UIControl.State.normal) mTopCenterBtn!.setTitleColor(UIColor.white, for: UIControl.State.normal) mTopCenterBtn!.titleLabel?.font = UIFont.systemFont(ofSize: 12) mTopCenterBtn!.isEnabled = false centerView() bottomButton() } override func viewDidDisappear(_ animated: Bool) { super.viewDidDisappear(animated) let sec:TimeInterval = ZZHHelper.getSecFromUserDefaultByKey(kNowTimeToUserDefaultKey_Home) Analytics.logEvent("home_pv", parameters: ["refer_page":"首页","duration":sec]) } //MARK: - 公司的平台---上报应用数据 func uploadAppInfo() { ZNetUtil.postUrl(urlStr: ZNetUtil.kUploadAppInfoUrl, params: ["eventName":"app_open"]) { result, error in print("上报回调...") } if ZZHHelper.checkAppIsFirstlanuch() { ZNetUtil.postUrl(urlStr: ZNetUtil.kUploadAppInfoUrl, params: ["eventName":"first_open"]) { result, error in print("上报回调...") } } } //MARK: - 监听设备投流 @objc private func airPlayStatusDidChange(_ notification: Notification) { checkAirPlayStatus() } private func checkAirPlayStatus() { print("设备连接变化 homecontroller") let currentRoute = AVAudioSession.sharedInstance().currentRoute let isAirPlayActive = currentRoute.outputs.contains { output in return output.portType == AVAudioSession.Port.HDMI || output.portType == AVAudioSession.Port.airPlay } mTopCenterBtn!.setTitle((isAirPlayActive ? NSLocalizedString("已连接外部设备", comment: "") : NSLocalizedString("未连接VR设备", comment: "")), for: UIControl.State.normal) mTopCenterBtn!.backgroundColor = isAirPlayActive ? UIColor.colorWithRGBINT(_r: 73, _g: 34, _b: 208) : UIColor.hexStringToColor(hexString: "#060507") isAirPlayActive ? mTopCenterBtn!.setImage(UIImage.init(named: "linked_button"), for: .normal) : mTopCenterBtn!.setImage(nil,for: .normal) isAirPlayActive ? mTopCenterBtn!.updateBtnEdgeInsets(style: .Left, space: 5):mTopCenterBtn!.updateBtnEdgeInsets(style: .Left, space: 0) } func centerView(){ //345*200 cycleScrollView = LLCycleScrollView() cycleScrollView?.frame = CGRect.init(x: 24, y: Int(SafeAreaTop_Height) + 35, width: Int(SCREEN_Width)-48 , height: (Int(SCREEN_Width) - 48) * 200/345) cycleScrollView!.delegate = self // 是否自动滚动 cycleScrollView!.autoScroll = true // 是否无限循环,此属性修改了就不存在轮播的意义了 😄 cycleScrollView!.infiniteLoop = true // 滚动间隔时间(默认为2秒) cycleScrollView!.autoScrollTimeInterval = 3.0 // 等待数据状态显示的占位图 cycleScrollView!.placeHolderImage = UIImage(named: "Banner_01") // 如果没有数据的时候,使用的封面图 cycleScrollView!.coverImage = UIImage(named: "Banner_01") // 设置图片显示方式=UIImageView的ContentMode cycleScrollView!.imageViewContentMode = .scaleToFill // 设置滚动方向( vertical || horizontal ) cycleScrollView!.scrollDirection = .horizontal // 设置当前PageControl的样式 (.none, .system, .fill, .pill, .snake) cycleScrollView!.customPageControlStyle = .snake // 非.system的状态下,设置PageControl的tintColor cycleScrollView!.customPageControlInActiveTintColor = UIColor.hexStringToColor(hexString: "#555555") // 设置.system系统的UIPageControl当前显示的颜色 cycleScrollView!.pageControlCurrentPageColor = UIColor.white // 非.system的状态下,设置PageControl的间距(默认为8.0) cycleScrollView!.customPageControlIndicatorPadding = 8.0 // 设置PageControl的位置 (.left, .right 默认为.center) cycleScrollView!.pageControlPosition = .center cycleScrollView!.pageControlBottom = -130 // 添加到view self.view.addSubview(cycleScrollView!) // 图片获取 cycleScrollView!.imagePaths = ["Banner_01","Banner_02","Banner_03"] mCenLab1 = UILabel() mCenLab1!.bounds = CGRect(x: 0, y: 0, width: SCREEN_Width - 30, height: 0) mCenLab1!.textColor = UIColor.white mCenLab1!.font = UIFont.boldSystemFont(ofSize: 18) self.view.addSubview(mCenLab1!) mCenLab1!.text = NSLocalizedString("Tips.1 拍摄空间照片以及视频", comment: "") mCenLab1!.sizeToFit() mCenLab1!.top = cycleScrollView!.bottom + 32 mCenLab1!.centerX = SCREEN_Width * 0.5 mCenLab2 = UILabel() mCenLab2!.numberOfLines = 3 mCenLab2!.textAlignment = NSTextAlignment.center mCenLab2!.bounds = CGRect(x: 0, y: 0, width: SCREEN_Width - 30, height: 0) mCenLab2!.textColor = UIColor.hexStringToColor(hexString: "#CDCDCD") mCenLab2!.font = UIFont.systemFont(ofSize: 14) self.view.addSubview(mCenLab2!) mCenLab2!.text = NSLocalizedString("一键拍摄空间格式的照片以及视频,留住美好瞬间", comment: "") mCenLab2!.sizeToFit() mCenLab2!.top = mCenLab1!.bottom + 16 mCenLab2!.centerX = SCREEN_Width * 0.5 } //滚动切换文本显示 func cycleScrollView(_ cycleScrollView: LLCycleScrollView, scrollTo index: NSInteger) { // print("当前页面索引:\(index)") let arr1 = [NSLocalizedString("Tips.1 拍摄空间照片以及视频", comment: ""),NSLocalizedString("Tips.2 视频转码", comment: ""),NSLocalizedString("Tips.3 直连VR设备", comment: "")] let arr2 = [NSLocalizedString("一键拍摄空间格式的照片以及视频,留住美好瞬间", comment: ""), NSLocalizedString("可以将任意格式视频转码为 VR 或 3D 格式", comment: ""), NSLocalizedString("可以通过链接VR设备,直接观看转码内容", comment: "")] DispatchQueue.main.async { [weak self] in self!.mCenLab1!.width = SCREEN_Width - 30 self!.mCenLab1!.text = arr1[index] self!.mCenLab1!.sizeToFit() self!.mCenLab1!.top = self!.cycleScrollView!.bottom + 32 self!.mCenLab1!.centerX = SCREEN_Width * 0.5 self!.mCenLab2!.width = SCREEN_Width - 30 self!.mCenLab2!.text = arr2[index] self!.mCenLab2!.sizeToFit() self!.mCenLab2!.top = self!.mCenLab1!.bottom + 16 self!.mCenLab2!.centerX = SCREEN_Width * 0.5 } } func cycleScrollView(_ cycleScrollView: LLCycleScrollView, didSelectItemIndex index: NSInteger) { print("用户点击了第\(index)个页面") } func bottomButton(){ let wd1 = (SCREEN_Width - 58)/2 let hi1 = wd1 * 80/167 let hi2 = wd1 * 172/167 //167*80 mBottomBtn1 = UIButton.init(type: UIButton.ButtonType.custom) self.view.addSubview(mBottomBtn1!) mBottomBtn1?.tag = 20 mBottomBtn1?.isSelected = false mBottomBtn1?.addTarget(self, action: #selector(navgationButtonClick2(sender:)), for: UIControl.Event.touchUpInside) mBottomBtn1?.frame = CGRect(x: 24, y: 10, width: wd1, height: hi1) mBottomBtn1!.bottom = SCREEN_Height - SafeAreaBottom_Height - 200 mBottomBtn1!.titleLabel?.font = UIFont.systemFont(ofSize: 12) mBottomBtn1?.setBackgroundImage(UIImage.init(named: NSLocalizedString("home_card", comment: "")), for: UIControl.State.normal) mBottomBtn2 = UIButton.init(type: UIButton.ButtonType.custom) self.view.addSubview(mBottomBtn2!) mBottomBtn2?.tag = 21 mBottomBtn2?.isSelected = false mBottomBtn2?.addTarget(self, action: #selector(navgationButtonClick2(sender:)), for: UIControl.Event.touchUpInside) mBottomBtn2?.frame = CGRect(x: 24, y: 10, width: wd1, height: hi1) mBottomBtn2!.top = mBottomBtn1!.bottom + 12 mBottomBtn2!.titleLabel?.font = UIFont.systemFont(ofSize: 12) mBottomBtn2?.setBackgroundImage(UIImage.init(named: NSLocalizedString("home_card_1", comment: "")), for: UIControl.State.normal) mBottomBtn3 = UIButton.init(type: UIButton.ButtonType.custom) self.view.addSubview(mBottomBtn3!) mBottomBtn3?.tag = 22 mBottomBtn3?.isSelected = false mBottomBtn3?.addTarget(self, action: #selector(navgationButtonClick2(sender:)), for: UIControl.Event.touchUpInside) mBottomBtn3?.frame = CGRect(x: 24, y: mBottomBtn1!.top, width: wd1, height: hi2) mBottomBtn3!.left = mBottomBtn1!.right + 10 mBottomBtn3!.titleLabel?.font = UIFont.systemFont(ofSize: 12) mBottomBtn3?.setBackgroundImage(UIImage.init(named: NSLocalizedString("home_card_2", comment: "")), for: UIControl.State.normal) } //MARK: - 打开相机、相薄、图库 @objc public func navgationButtonClick2(sender:UIButton){ print("nihao") //侧边栏 if(sender.tag == 11){ addMenu() } if(sender.tag == 10) {//右上角会员入口 let vc:MembershipVC = MembershipVC() let nav = UINavigationController(rootViewController: vc) nav.modalTransitionStyle = UIModalTransitionStyle.coverVertical nav.modalPresentationStyle = .fullScreen self.present(nav, animated: true) if !UserInfo.sharedInstance.isMemberShip {//统计 Analytics.logEvent("home_unvip_click", parameters: nil) } } if sender.tag == 20 { // if UserInfo.sharedInstance.isMemberShip { let vc:CCSpatialShootController = CCSpatialShootController() self.navigationController?.pushViewController(vc, animated: true) // } // else { // } }else if sender.tag == 21{ //空间转码 // gotoSpatialPlayVC() // CCBottomMenuPopView.share.show(imageNameArray: ["Icon_PopUp_Icon_Scenes","Icon_PopUp_Icon_Photo","Icon_PopUp_Icon_Folder"], textArray: ["空间相簿","照片图库","本机文件"]) { index in CCBottomMenuPopView.share.show(imageNameArray: ["Icon_PopUp_Icon_Scenes","Icon_PopUp_Icon_Photo"], textArray: [NSLocalizedString("空间相簿", comment: ""),NSLocalizedString("照片图库", comment: "")]) { index in if index == 0 { self.spaceAlbum() }else if index == 1 { self.photoLibrary() } } }else if sender.tag == 22 { //VR预览 let view = CCSpaceAlbumFilterPopView2.init(frame: CGRectMake(0, 0, KScreenWidth, KScreenHeight)) self.view.addSubview(view) view.show() //选择图片 view.selectedImageHandler = { [weak self] data,asset in print("回调") let vc = CCSpatialPhotoDisplayController() vc.photoOriginalData = data vc.imageAsset = asset self?.navigationController?.pushViewController(vc, animated: true) } //选择视频 view.selectedVideoHandler = {[weak self] url,asset in if (asset.duration > 60 ) { 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) return } } let vc = CCSpatialVideoDisplayController() vc.sourceVideoURL = url vc.videoOriginalPHAsset = asset self?.navigationController?.pushViewController(vc, animated: true) } } } func addMenu(){ let vc = MenuVC() self.navigationController?.pushViewController(vc, animated: true) return mBackView = UIView(frame: self.view.bounds) mBackView!.backgroundColor = UIColor.colorWithRGB(_r: 0, _g: 0, _b: 0, alpha: 0.01) self.view.addSubview(mBackView!) // mTopView = UIView(frame: CGRect(x: 0, y: -StatuBar_Height, width: SCREEN_Width, height: StatuBar_Height)) // mTopView?.backgroundColor = UIColor.hexStringToColor(hexString: "#2C2737") // self.view.addSubview(mTopView!) let tap:UITapGestureRecognizer = UITapGestureRecognizer.init(target: self, action: #selector(tapsender(sender:))) mBackView!.addGestureRecognizer(tap) mineView = CCMineView(frame: CGRect.init(x: -SCREEN_Width, y: 0, width: SCREEN_Width-108, height: SCREEN_Height)) self.view.addSubview(mineView!) mineView!.handle = {dic in print(dic["name"] as Any) if((dic["name"] as! String).elementsEqual(NSLocalizedString("隐私政策", comment: ""))){ let vc:CCWebController = CCWebController() vc.titleValue = NSLocalizedString("隐私政策", comment: "") let sizeUrl = NSLocalizedString("siteUrl", comment: "隐私政策url") vc.urlString = sizeUrl self.navigationController?.pushViewController(vc, animated: true) } else if((dic["name"] as! String).elementsEqual(NSLocalizedString("用户协议", comment: ""))){ let vc:CCWebController = CCWebController() vc.titleValue = NSLocalizedString("用户协议", comment: "") let sizeUrl = NSLocalizedString("userSiteUrl", comment: "用户协议url") vc.urlString = sizeUrl self.navigationController?.pushViewController(vc, animated: true) } else if((dic["name"] as! String).elementsEqual(NSLocalizedString("联系我们", comment: ""))) {//联系我们 if !MFMailComposeViewController.canSendMail() { SVProgressHUD.showInfo(withStatus: NSLocalizedString("请先前往系统设置配置发送的邮箱信息", comment: "")) return } let mailComposeViewController = MFMailComposeViewController() mailComposeViewController.mailComposeDelegate = self mailComposeViewController.setSubject("") mailComposeViewController.setMessageBody(NSLocalizedString("请在此处描述您需要反馈的问题.", comment: ""), isHTML: false) mailComposeViewController.setToRecipients(["fangaoqdi@163.com"]) self.present(mailComposeViewController, animated: true) } self.deleteMenu() } addAnimation() } func addAnimation(){ UIView.animate(withDuration: 0.25) { [weak self] in // self!.mTopView?.top = 0 self!.mineView!.left = 0 self!.mBackView!.backgroundColor = UIColor.colorWithRGB(_r: 0, _g: 0, _b: 0, alpha: 0.5) } completion: { re in } } func deleteMenu(){ UIView.animate(withDuration: 0.25) { [weak self] in // self!.mTopView?.bottom = 0 self!.mineView!.left = -SCREEN_Width self!.mBackView!.backgroundColor = UIColor.colorWithRGB(_r: 0, _g: 0, _b: 0, alpha: 0.01) } completion: {[weak self] re in // self!.mTopView?.removeFromSuperview() // self!.mTopView = nil self!.mineView?.removeFromSuperview() self!.mineView = nil self!.mBackView?.removeFromSuperview() self!.mBackView = nil } } @objc public func tapsender(sender:UITapGestureRecognizer){ deleteMenu() } } extension CCHomeController: TZImagePickerControllerDelegate,UINavigationControllerDelegate,UIImagePickerControllerDelegate{ func spaceAlbum() { self.view.addSubview(spaceAlbumPopView) spaceAlbumPopView.show() //选择图片 spaceAlbumPopView.selectedImageHandler = { [self] data,asset in gotoPhotoTransformVC(data: data, url: nil,asset: asset) } //选择视频 spaceAlbumPopView.selectedVideoHandler = { [weak self] url,asset in if (asset.duration > 60 ) { 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) return } } self?.gotoVideoTransformVC(url: url,asset: asset) } } func gotoPhotoTransformVC(data:Data?,url:URL?,asset:PHAsset?) { let vc = VRPhotoTransformController() vc.sourceImageData = data vc.sourceImageURL = url vc.imageAsset = asset self.navigationController?.pushViewController(vc, animated: true) } func gotoVideoTransformVC(url:URL?,asset:PHAsset?) { let vc = VRVideoTransformController() vc.sourceVideoURL = url vc.videoOriginalPHAsset = asset self.navigationController?.pushViewController(vc, animated: true) } func photoLibrary() { //判断权限 let status = AVCaptureDevice.authorizationStatus(for: .video) if status == AVAuthorizationStatus.restricted || status == AVAuthorizationStatus.denied { let alertC = UIAlertController(title: NSLocalizedString(NSLocalizedString("无法使用相机", comment: ""), comment: ""), message: NSLocalizedString("请前往[设置->隐私安全]中开启访问授权", comment: ""), preferredStyle: .alert) // let actionCancel = UIAlertAction(title: "Cancel", style: .cancel) { (action:UIAlertAction) in // } let actionSet = UIAlertAction(title: NSLocalizedString("设置", comment: ""), style: .cancel) { (action:UIAlertAction) in let url:URL = URL(string: UIApplication.openSettingsURLString)! UIApplication.shared.open(url, options: [:], completionHandler: nil) } // alertC.addAction(actionCancel) alertC.addAction(actionSet) self.present(alertC, animated: true, completion: nil) }else{ //相册 let picker = UIImagePickerController.init() picker.delegate = self; picker.mediaTypes = ["public.image","public.movie"]; picker.sourceType = .photoLibrary; self.present(picker, animated: true, completion: nil) } } // MARK: - ========== UIImagePickerControllerDelegate ========== func imagePickerController(_ picker: UIImagePickerController, didFinishPickingMediaWithInfo info: [UIImagePickerController.InfoKey : Any]) { print("info = \(info)") if let mediaType = info[.mediaType] as? String { switch mediaType { case "public.image": //获取照片的原图 // let image : UIImage = info[.originalImage] as! UIImage //获取图片的url let imageUrl : URL = info[.imageURL] as! URL print("选择图片 Selected iamge URL: \(String(describing: imageUrl))") //PHAsset // let phAsset : PHAsset = info[UIImagePickerController.InfoKey.phAsset] as! PHAsset gotoPhotoTransformVC(data: nil, url: imageUrl,asset: info[.phAsset] as? PHAsset) break case "public.movie": let videoURL = info[.mediaURL] as? URL print("选择视频 Selected video URL: \(String(describing: videoURL))") gotoVideoTransformVC(url: videoURL,asset: info[.phAsset] as? PHAsset) // sourceVideoURL = videoURL // heroAsset1 = AVAsset(url: sourceVideoURL!) // heroAsset = heroAsset1 // if(!isSpatialVideo(asset: heroAsset!)){ // showTextAlert(title: "提示", message: "当前视频不是空间视频") // } // play() break default: print("未知的媒体类型") break } } picker.dismiss(animated: true, completion: nil) // if self.photosArray.count >= self.maxImages { // return SVProgressHUD.showInfo(withStatus: "Add up to \(self.maxImages) photos") // } // self.addPicture(image) } func imagePickerControllerDidCancel(_ picker: UIImagePickerController) { picker.dismiss(animated: true, completion: nil) } // MARK: - ========== TZImagePickerControllerDelegate ========== func imagePickerController(_ picker: TZImagePickerController!, didFinishPickingPhotos photos: [UIImage]!, sourceAssets assets: [Any]!, isSelectOriginalPhoto: Bool, infos: [[AnyHashable : Any]]!) { // if self.photosArray.count >= self.maxImages { // return SVProgressHUD.showInfo(withStatus: "Add up to \(self.maxImages) photos") // } // // //判断可添加的剩余数量 // if photos.count > self.maxImages - self.photosArray.count { // let surplus = self.maxImages - self.photosArray.count // return SVProgressHUD.showInfo(withStatus: "Up to \(surplus) more photos can be added") // } // // self.addPictures(photos) // selectedPhotos.append(contentsOf: photos) // selectedAssets.append(contentsOf: assets) // listTableView.reloadData() } func mailComposeController(_ controller: MFMailComposeViewController, didFinishWith result: MFMailComposeResult, error: Error?) { controller.dismiss(animated: true) if let error = error { print(error) } else { switch result { case .cancelled: print("Mail cancelled") case .sent: print("Mail sent") case .failed: print("Mail failed") case .saved: print("Mail saved") default: break } } } }