react-native-multiple-image-picker icon indicating copy to clipboard operation
react-native-multiple-image-picker copied to clipboard

[iOS] Lỗi đóng modal khi người dùng cancel picker và app bị đóng băng

Open huyth-2224 opened this issue 3 years ago • 0 comments

Mình cũng đang gặp một trường hợp giống như issue này. https://github.com/baronha/react-native-multiple-image-picker/issues/3

Step 1: mở 1 modal lên ( trong đó một nút upload để mở image picker ) Step 2: sau khi nhấn nút upload, mở image picker , người dùng nhấn cancel

Kết quả:

  • image picker đóng và modal của mình cũng bị đóng theo. Đồng thời app bị đơ ( do có 1 View chê lại toàn bộ )

Mình đã đọc và sửa lỗi để giải quyết như sau:

  • mở file /react-native-multiple-image-picker/ios/MultipleImagePicker.swift
  • Khai báo thêm 1 biến là var isUserCancelImagePicker = false
  • Trong hàm photoPickerDidCancel() => mình bật biến đó lên isUserCancelImagePicker = true
  • Trong hàm dismissComplete() mình sửa lại như sau
     func dismissComplete(){
      if !self.isUserCancel {
         DispatchQueue.main.async {
             self.getTopMostViewController()?.dismiss(animated: true, completion: nil)
         }
      }
      self.isUserCancel = false
     }

mình đã test trên iOS của mình thì thấy OK.

hy vọng bạn sẽ check và nếu ổn định, có thể đưa vào bản build mới.

huyth-2224 avatar Jan 21 '22 23:01 huyth-2224