"swiftui profile picture" Code Answer's

You're definitely familiar with the best coding language Swift that developers use to develop their projects and they get all their queries like "swiftui profile picture" answered properly. Developers are finding an appropriate answer about swiftui profile picture related to the Swift coding language. By visiting this online portal developers get answers concerning Swift codes question like swiftui profile picture. Enter your desired code related query in the search bar and get every piece of information about Swift code related question on swiftui profile picture. 

swiftui profile picture

By Easy EarthwormEasy Earthworm on Dec 03, 2020
import SwiftUI

public struct ImagePickerView: UIViewControllerRepresentable {

    private let sourceType: UIImagePickerController.SourceType
    private let onImagePicked: (UIImage) -> Void
    @Environment(\.presentationMode) private var presentationMode

    public init(sourceType: UIImagePickerController.SourceType, onImagePicked: @escaping (UIImage) -> Void) {
        self.sourceType = sourceType
        self.onImagePicked = onImagePicked
    }

    public func makeUIViewController(context: Context) -> UIImagePickerController {
        let picker = UIImagePickerController()
        picker.sourceType = self.sourceType
        picker.delegate = context.coordinator
        return picker
    }

    public func updateUIViewController(_ uiViewController: UIImagePickerController, context: Context) {}

    public func makeCoordinator() -> Coordinator {
        Coordinator(
            onDismiss: { self.presentationMode.wrappedValue.dismiss() },
            onImagePicked: self.onImagePicked
        )
    }

    final public class Coordinator: NSObject, UINavigationControllerDelegate, UIImagePickerControllerDelegate {

        private let onDismiss: () -> Void
        private let onImagePicked: (UIImage) -> Void

        init(onDismiss: @escaping () -> Void, onImagePicked: @escaping (UIImage) -> Void) {
            self.onDismiss = onDismiss
            self.onImagePicked = onImagePicked
        }

        public func imagePickerController(_ picker: UIImagePickerController, didFinishPickingMediaWithInfo info: [UIImagePickerController.InfoKey: Any]) {
            if let image = info[.originalImage] as? UIImage {
                self.onImagePicked(image)
            }
            self.onDismiss()
        }

        public func imagePickerControllerDidCancel(_: UIImagePickerController) {
            self.onDismiss()
        }

    }

}

Source: stackoverflow.com

Add Comment

0

All those coders who are working on the Swift based application and are stuck on swiftui profile picture can get a collection of related answers to their query. Programmers need to enter their query on swiftui profile picture related to Swift code and they'll get their ambiguities clear immediately. On our webpage, there are tutorials about swiftui profile picture for the programmers working on Swift code while coding their module. Coders are also allowed to rectify already present answers of swiftui profile picture while working on the Swift language code. Developers can add up suggestions if they deem fit any other answer relating to "swiftui profile picture". Visit this developer's friendly online web community, CodeProZone, and get your queries like swiftui profile picture resolved professionally and stay updated to the latest Swift updates. 

Swift answers related to "swiftui profile picture"

View All Swift queries

Swift queries related to "swiftui profile picture"

Browse Other Code Languages

CodeProZone