Skip to content

Commit ec972e9

Browse files
committed
fix controller in ios
1 parent 24e2b91 commit ec972e9

File tree

2 files changed

+6
-5
lines changed

2 files changed

+6
-5
lines changed

ios/MultipleImagePicker.swift

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,6 @@ class MultipleImagePicker: NSObject, TLPhotosPickerViewControllerDelegate,UINavi
1818
var videoAssets = [PHAsset]()
1919
var videoCount = 0
2020
// controller
21-
var controller = UIViewController()
22-
2321

2422

2523

@@ -52,11 +50,14 @@ class MultipleImagePicker: NSObject, TLPhotosPickerViewControllerDelegate,UINavi
5250
}
5351

5452
func dismissComplete() {
55-
53+
DispatchQueue.main.async {
54+
self.getTopMostViewController()?.dismiss(animated: true, completion: nil)
55+
}
5656
}
5757

5858
@objc(openPicker:withResolver:withRejecter:)
5959
func openPicker(options: NSDictionary, resolve:@escaping RCTPromiseResolveBlock,reject:@escaping RCTPromiseRejectBlock) -> Void {
60+
videoCount = 0
6061
self.setConfiguration(options: options, resolve: resolve, reject: reject)
6162
let viewController = CustomPhotoPickerViewController()
6263
viewController.delegate = self
@@ -70,7 +71,6 @@ class MultipleImagePicker: NSObject, TLPhotosPickerViewControllerDelegate,UINavi
7071
viewController.modalTransitionStyle = .coverVertical
7172
viewController.modalPresentationStyle = .overCurrentContext
7273

73-
controller = viewController
7474
DispatchQueue.main.async {
7575
self.getTopMostViewController()?.present(viewController, animated: true, completion: nil)
7676
}
@@ -275,7 +275,7 @@ class MultipleImagePicker: NSObject, TLPhotosPickerViewControllerDelegate,UINavi
275275
print("maxVideo", maxVideo)
276276
if(phAsset.mediaType == .video){
277277
if(videoCount == maxVideo as! Int){
278-
showExceededMaximumAlert(vc: self.controller, isVideo: true)
278+
showExceededMaximumAlert(vc: self.getTopMostViewController()!, isVideo: true)
279279
return false
280280
}
281281
videoCount += 1

react-native-multiple-image-picker.podspec

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ Pod::Spec.new do |s|
1212

1313
s.platforms = { :ios => "10.0" }
1414
s.source = { :git => "https://github.com/baronha/react-native-multiple-image-picker.git", :tag => "#{s.version}" }
15+
s.swift_version = '5.0'
1516

1617
s.source_files = "ios/**/*.{h,m,mm,swift,lproj}"
1718

0 commit comments

Comments
 (0)