Skip to content

Instantly share code, notes, and snippets.

@yungblud
Last active April 12, 2021 06:56
Show Gist options
  • Select an option

  • Save yungblud/51af7c36465f471fa2a5d85d97f6f6a2 to your computer and use it in GitHub Desktop.

Select an option

Save yungblud/51af7c36465f471fa2a5d85d97f6f6a2 to your computer and use it in GitHub Desktop.
image picker source code swift
func launchLibrary() -> Void {
guard let callback = self.globalCallback else { return }
let fetchOptions = PHFetchOptions()
fetchOptions.includeAssetSourceTypes = .typeUserLibrary
fetchOptions.sortDescriptors = [.init(key: "creationDate", ascending: false)]
self.fetchedAssets = PHAsset.fetchAssets(with: .image, options: fetchOptions)
self.imageShowerViewController = ImageShowerViewController(fetchedAssets: self.fetchedAssets, options: self.options, callback: callback)
guard let imageShowerViewController = self.imageShowerViewController else { return }
PHPhotoLibrary.shared().register(self)
DispatchQueue.main.async {
guard let rootViewController = RCTPresentedViewController() else { return }
let navigationController = UINavigationController(rootViewController: imageShowerViewController)
navigationController.modalPresentationStyle = .overFullScreen
rootViewController.present(navigationController, animated: true, completion: nil)
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment