Browse Source

录音按钮不弹起的bug

harry 3 years ago
parent
commit
c6f3a3a051

+ 25 - 12
BFRecordScreenKit/Classes/RecordScreen/Controller/BFRecordScreenController.swift

@@ -847,13 +847,17 @@ public class BFRecordScreenController: BFBaseViewController {
         switch recognizer.state {
         case .began:
             touchStart = recognizer.location(in: bottomeView)
-            beginOnStartBtn = recordBtn.frame.contains(touchStart)
+            beginOnStartBtn = (beginOnStartBtn || recordBtn.frame.contains(touchStart))
+            BFLog(1, message: "beginOnStartBtn:\(beginOnStartBtn)")
         case .changed:
             if beginOnStartBtn == true {
                 let nowPoint = recognizer.location(in: bottomeView)
                 BFLog(1, message: "nowPoint x: \(nowPoint.x) y:\(nowPoint.y)")
                 if recordBtn.frame.contains(nowPoint) {
-                } else {}
+                
+                } else {
+                    
+                }
             }
 
         case .ended:
@@ -973,12 +977,11 @@ public class BFRecordScreenController: BFBaseViewController {
         if isDragingProgressSlder {
             return
         }
-        // 开始时间
-        let model = PQVoiceModel()
-        model.startCMTime = currentAssetProgress
-        isRecording = true
+ 
+        
+
 //        progressThumV.progressView.isUserInteractionEnabled = false
-        collectionView.isScrollEnabled = false
+//        collectionView.isScrollEnabled = false
         // 开始录制时清除屏幕上的字幕
         subtitleLabel.text = ""
         subtitleLabel.backgroundColor = UIColor.clear
@@ -988,9 +991,16 @@ public class BFRecordScreenController: BFBaseViewController {
             BFLog(message: "录音机初始化错误!!!")
             return
         }
+        
+        
+        // 开始时间
+        beginOnStartBtn = true
+        isRecording = true
 
-        view.isUserInteractionEnabled = false
+        UIApplication.shared.keyWindow?.isUserInteractionEnabled = false
 
+        let model = PQVoiceModel()
+        model.startCMTime = currentAssetProgress
         model.volume = 100
         recorderManager?.voiceModel = model
         recorderManager?.startRecord()
@@ -1023,11 +1033,13 @@ public class BFRecordScreenController: BFBaseViewController {
         if !isRecording {
             return
         }
+        beginOnStartBtn = false
+
         isRecording = false
 //        progressThumV.progressView.isUserInteractionEnabled = true
-        collectionView.isScrollEnabled = true
+//        collectionView.isScrollEnabled = true
 
-        view.isUserInteractionEnabled = true
+        UIApplication.shared.keyWindow?.isUserInteractionEnabled = true
         recorderManager?.stopRecord(isCancel: false)
 
         if currentAssetProgress.seconds - (recorderManager?.voiceModel?.startCMTime.seconds ?? 0) >= 1.0 {
@@ -1053,8 +1065,9 @@ public class BFRecordScreenController: BFBaseViewController {
     @objc func cancleRecord() {
         isRecording = false
         recorderManager?.stopRecord(isCancel: true)
-        progressThumV.progressView.isUserInteractionEnabled = true
-        collectionView.isScrollEnabled = true
+//        progressThumV.progressView.isUserInteractionEnabled = true
+//        collectionView.isScrollEnabled = true
+        UIApplication.shared.keyWindow?.isUserInteractionEnabled = true
         pause()
     }