Функция не работает в UIViewControllerRepresentable - PullRequest
1 голос
/ 17 января 2020

Я пытаюсь реализовать компонент unspla sh -photopicker- ios в SwiftUI через UIViewControllerRepresentable. Представление запускается успешно, но функция unsplashPhotoPicker не работает, она всегда возвращает ноль, может кто-нибудь сказать мне, в чем проблема.

import SwiftUI
import UnsplashPhotoPicker

struct UnsplashImagePicker: UIViewControllerRepresentable {

    var urlUnsplashImage = [UnsplashPhoto]()

    let configuration = UnsplashPhotoPickerConfiguration(
      accessKey: "f99d21d6eb682196455dd29b621688aff2d525c7c3a7f95bfcb05d497f38f5dc",
      secretKey: "ccff858162e795c062ce13e9d16a2cf607076d0eb185141e35b14f589b1cd713",
      allowsMultipleSelection: false)

    func makeUIViewController(context: UIViewControllerRepresentableContext<UnsplashImagePicker>) -> UnsplashPhotoPicker {
        let unsplashImagePicker = UnsplashPhotoPicker(configuration: configuration)
        unsplashImagePicker.delegate = context.coordinator
        return unsplashImagePicker
    }

    func makeCoordinator() -> UnsplashImagePicker.Coordinator {
        Coordinator(self)
    }

    class Coordinator: NSObject, UnsplashPhotoPickerDelegate, UINavigationControllerDelegate {
        var parent: UnsplashImagePicker
        init(_ parent: UnsplashImagePicker) {
            self.parent = parent
        }

        func unsplashPhotoPicker(_ photoPicker: UnsplashPhotoPicker, didSelectPhotos photos: [UnsplashPhoto]) {
            print(photos)
        }

        func unsplashPhotoPickerDidCancel(_ photoPicker: UnsplashPhotoPicker) {
            print("Unsplash photo picker did cancel")
        }
    }

    func updateUIViewController(_ uiViewController: UnsplashPhotoPicker, context: UIViewControllerRepresentableContext<UnsplashImagePicker>) {

    }
}
Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...