You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Hi, I am doing the library integration via SPM to my project in SwiftUI, but I have a problem because the Done at the top of the Tatsi view is not called and I can't get the selected images.
The code for the integration via UIViewControllerRepresentable is as follows:
import SwiftUI
import UIKit
// 1. Add Import Tatsi and Import Photos to your Swift
import Tatsi
import Photos
struct TatsiViewController: UIViewControllerRepresentable {
@Binding var show: Bool
func makeCoordinator() -> Coordinator {
Coordinator(self)
}
func makeUIViewController(context: UIViewControllerRepresentableContext<TatsiViewController>) -> TatsiPickerViewController {
// 2. (Optional) Create an instance of TatsiConfig and configure the settings.
var config = TatsiConfig.default
config.showCameraOption = false
config.supportedMediaTypes = [.image]
config.firstView = .userLibrary
// 3. Create an instance of TatsiPickerViewController. TatsiPickerViewController(config:) allows you to use the config from the previous step
let pickerViewController = TatsiPickerViewController(config: config)
// 5. Set the pickerDelegate on TatsiPickerViewController
pickerViewController.delegate = context.coordinator
// 6. Present the TatsiPickerViewController
return pickerViewController
}
func updateUIViewController(_ uiViewController: TatsiPickerViewController, context: UIViewControllerRepresentableContext<TatsiViewController>) {
uiViewController.delegate = context.coordinator
}
// 4. Implement TatsiPickerViewControllerDelegate
final class Coordinator: NSObject, TatsiPickerViewControllerDelegate, UINavigationControllerDelegate {
var parent: TatsiViewController
init(_ parent: TatsiViewController) {
self.parent = parent
}
func pickerViewController(_ pickerViewController: TatsiPickerViewController, didPickAssets assets: [PHAsset]) {
print("Picked assets: \(assets)")
parent.show = false
}
func imagePickerControllerDidCancel(_ picker: UIImagePickerController) {
picker.dismiss(animated: true, completion: nil)
parent.show = false
}
func imagePickerController(_ picker: UIImagePickerController, didFinishPickingMediaWithInfo info: [UIImagePickerController.InfoKey : Any]) {
picker.dismiss(animated: true, completion: nil)
parent.show = false
}
}
}
What do I need to integrate in order to obtain the selected images? Thank you!
The text was updated successfully, but these errors were encountered:
Is what will be called when the done button is pressed, with the assets the user has selected. Here you are also responsible for dismissing the pickerViewController yourself.
Hi, I am doing the library integration via SPM to my project in SwiftUI, but I have a problem because the Done at the top of the Tatsi view is not called and I can't get the selected images.
The code for the integration via UIViewControllerRepresentable is as follows:
What do I need to integrate in order to obtain the selected images? Thank you!
The text was updated successfully, but these errors were encountered: