ソースを参照

1.修复1.6(2)bug
2.解决通知 block 的循环引用
3.解决 cell 左滑删除代理循环引用问题

100Years 3 週間 前
コミット
d698d8d52e

+ 2 - 1
AIRingtone/Business/TSAIPhotoVC/TSAIPhotoChildVC/TSAIPhotoChildVC.swift

@@ -88,7 +88,8 @@ class TSAIPhotoChildVC: TSBaseVC {
     
     override func dealThings() {
         reloadView()
-        NotificationCenter.default.addObserver(forName: .kReloadUIData, object: nil, queue: nil) { notification in
+        NotificationCenter.default.addObserver(forName: .kReloadUIData, object: nil, queue: nil) { [weak self] notification in
+            guard let self = self else { return }
             if let userInfo = notification.userInfo as? [String: TSGennerateType], let myEnum = userInfo["TSGennerateType"] {
                 if myEnum == self.style {
                     self.vm.setRecentData()

+ 2 - 1
AIRingtone/Business/TSAIPhotoVC/TSAIPhotoVC.swift

@@ -141,7 +141,8 @@ class TSAIPhotoVC: TSBaseVC {
     
     
     override func dealThings() {
-        NotificationCenter.default.addObserver(forName: .kReloadUIData, object: nil, queue: nil) { notification in
+        NotificationCenter.default.addObserver(forName: .kReloadUIData, object: nil, queue: nil) { [weak self] notification in
+            guard let self = self else { return }
             if let userInfo = notification.userInfo as? [String: TSGennerateType], let myEnum = userInfo["TSGennerateType"] {
                 self.segmentedView.selectItemAt(index: myEnum.rawValue)
             }

+ 1 - 1
AIRingtone/Business/TSAIPhotoVC/TSTextGeneralPicVC/View/TSPromptStyleView.swift

@@ -142,7 +142,7 @@ class TSPTPSelectStyleCCell: TSBaseCollectionCell {
 
     lazy var textLabel: UILabel = {
         let textLabel = UILabel.createLabel(font: .font(size: 14),textColor: .white,textAlignment: .center,numberOfLines: 0)
-        textLabel.addShadow(shadowColor: UIColor.black.cgColor, shadowOffset: CGSize(width: 0, height: 2), shadowRadius: 2, shadowOpacity: 0.3)
+        textLabel.addShadow(shadowColor: UIColor.black.cgColor, shadowOffset: CGSize(width: 0, height: 2), shadowRadius: 2, shadowOpacity: 0.6)
         return textLabel
     }()
     

+ 6 - 2
AIRingtone/Business/TSAIRintoneVC/TSAIRintoneVC/TSAIRintoneVC.swift

@@ -108,6 +108,8 @@ class TSAIRintoneVC: TSBaseVC {
 
     override func viewWillAppear(_ animated: Bool) {
         super.viewWillAppear(animated)
+        viewModel.updateRecentData()
+        updateListView()
     }
     
     override func viewWillDisappear(_ animated: Bool) {
@@ -122,7 +124,8 @@ class TSAIRintoneVC: TSBaseVC {
             collectionView.reloadData()
         }
         
-        NotificationCenter.default.addObserver(forName: .kGenerateRintoneOperationChanged, object: nil, queue: nil) { notification in
+        NotificationCenter.default.addObserver(forName: .kGenerateRintoneOperationChanged, object: nil, queue: nil) { [weak self] notification in
+            guard let self = self else { return }
             if let userInfo = notification.userInfo as? [String: Any], let uuid = userInfo["uuid"] as? String,let state = userInfo["state"] as? TSProgressState {
                 dePrint("TSBaseOperation stateDatauPblished 收到 = \(state)")
                 switch state {
@@ -174,7 +177,8 @@ extension TSAIRintoneVC: UICollectionViewDataSource ,UICollectionViewDelegate,UI
             let itemModel = sectionModel.list.safeObj(At: indexPath.item),
            let cell = cell as? TSAIRintoneHistoryCell
         {
-            cell.delegate = self
+            weak var weakSelf = self
+            cell.delegate = weakSelf
             cell.setRingBtn.indexPath = indexPath
             cell.setRingBtn.addTarget(self, action: #selector(clickSetRingBtn(_ :)), for: .touchUpInside)
             if let model = itemModel as? TSActionInfoModel {

+ 2 - 1
AIRingtone/Business/TSAIRintoneVC/TSAIRintoneVC/View/TSAIRintoneHistoryCell.swift

@@ -132,7 +132,8 @@ class TSAIRintoneHistoryCell: SwipeCollectionViewCell  {
     }
     
     func dealThings(){
-        NotificationCenter.default.addObserver(forName: .kBusinessAudioStateChange, object: nil, queue: nil) { notification in
+        NotificationCenter.default.addObserver(forName: .kBusinessAudioStateChange, object: nil, queue: nil) {[weak self] notification in
+            guard let self = self else { return }
             if let userInfo = notification.userInfo as? [String: TSBusinessAudioPlayer.PlayerState], let state = userInfo["PlayerState"] {
                 kExecuteOnMainThread {
                     self.changePlayerState(state: state)

+ 12 - 8
AIRingtone/Business/TSAIRintoneVC/TSGenerateHistoryVC/TSGenerateHistoryVC.swift

@@ -74,7 +74,8 @@ class TSGenerateHistoryVC: TSBaseVC {
     override func dealThings() {
         updateListView()
         
-        NotificationCenter.default.addObserver(forName: .kGenerateRintoneOperationChanged, object: nil, queue: nil) { notification in
+        NotificationCenter.default.addObserver(forName: .kGenerateRintoneOperationChanged, object: nil, queue: nil) {[weak self] notification in
+            guard let self = self else { return }
             if let userInfo = notification.userInfo as? [String: Any],let state = userInfo["state"] as? TSProgressState {
                 switch state {
                 case .start, .success(_),.failed(_),.none:
@@ -90,10 +91,11 @@ class TSGenerateHistoryVC: TSBaseVC {
         collectionView.reloadData()
     }
     
-    override func navBarClickLeftAction() {
-        super.navBarClickLeftAction()
-        self.reloadUIBlock?()
-    }
+//    override func navBarClickLeftAction() {
+//        super.navBarClickLeftAction()
+//        self.reloadUIBlock?()
+//    }
+
 }
 
 extension TSGenerateHistoryVC: UICollectionViewDataSource ,UICollectionViewDelegate,UICollectionViewDelegateFlowLayout {
@@ -117,9 +119,10 @@ extension TSGenerateHistoryVC: UICollectionViewDataSource ,UICollectionViewDeleg
             let itemModel = sectionModel.list.safeObj(At: indexPath.item),
            let cell = cell as? TSAIRintoneHistoryCell
         {
-            cell.delegate = self
+            weak var weakSelf = self
+            cell.delegate = weakSelf
             cell.setRingBtn.indexPath = indexPath
-            cell.setRingBtn.addTarget(self, action: #selector(clickSetRingBtn(_ :)), for: .touchUpInside)
+            cell.setRingBtn.addTarget(weakSelf, action: #selector(clickSetRingBtn(_ :)), for: .touchUpInside)
             if let model = itemModel as? TSActionInfoModel {
                 cell.model = model
             }else if let ringModel = itemModel as? TSRingModel {
@@ -177,7 +180,8 @@ extension TSGenerateHistoryVC: SwipeCollectionViewCellDelegate {
         // 删除操作
         let deleteAction = SwipeAction(style: .destructive, title: nil) {[weak self] action, indexPath in
             guard let self = self else { return }
-            showCustomAlert(message: "Are you sure to delete".localized, deleteHandler:  {
+            showCustomAlert(message: "Are you sure to delete".localized, deleteHandler:  { [weak self]  in
+                guard let self = self else { return }
                 if let sectionModel = self.viewModel.modelList.safeObj(At: indexPath.section),
                 let model = sectionModel.list.safeObj(At: indexPath.item){
                     if let model = model as? TSActionInfoModel {

+ 1 - 1
AIRingtone/Business/TSDiscoverVC/TSDiscoverVC/View/TSDiscoverCell.swift

@@ -23,7 +23,7 @@ class TSDiscoverCell: TSBaseCollectionCell {
     
     lazy var textLabel: UILabel = {
         let textLabel = UILabel.createLabel(font: .font(size: 14),textColor: .white,textAlignment: .center,numberOfLines: 0)
-        textLabel.addShadow(shadowColor: UIColor.black.cgColor, shadowOffset: CGSize(width: 0, height: 2), shadowRadius: 2, shadowOpacity: 0.3)
+        textLabel.addShadow(shadowColor: UIColor.black.cgColor, shadowOffset: CGSize(width: 0, height: 2), shadowRadius: 2, shadowOpacity: 0.6)
         return textLabel
     }()
     

+ 2 - 1
AIRingtone/Business/TSDiscoverVC/TSRingDownVC/TSRingDownVC.swift

@@ -123,7 +123,8 @@ extension TSRingDownVC: UICollectionViewDataSource ,UICollectionViewDelegate,UIC
             let itemModel = sectionModel.list.safeObj(At: indexPath.item),
            let cell = cell as? TSAIRintoneHistoryCell
         {
-            cell.delegate = self
+            weak var weakSelf = self
+            cell.delegate = weakSelf
             cell.setRingBtn.indexPath = indexPath
             cell.setRingBtn.addTarget(self, action: #selector(clickSetRingBtn(_ :)), for: .touchUpInside)
             if let model = itemModel as? TSActionInfoModel {

+ 1 - 1
AIRingtone/Business/TSSetingVC/SetingVC/TSSetingModel.swift

@@ -7,7 +7,7 @@
 
 enum SettingType: String, CaseIterable {
     case tutorial = "Tutorial"
-    case update = "Update"
+    case update = "Update Version"
     case rateus = "Rate us"
     case shareus = "Share us"
     case privacy = "Privacy Policy"

+ 1 - 1
AIRingtone/Business/VIewTool/TSRingToneCellView.swift

@@ -238,7 +238,7 @@ class TSRingToneGenerateView:TSBaseView {
         generateProgressView.isHidden = false
         refreshBtn.isHidden = true
         let progressInt = Int(progress*100)
-        infoLabel.text = "Working On Your Ringtone \(progressInt)%..."
+        infoLabel.text = "Working on your ringtone \(progressInt)%..."
     }
     
     func setFail(){