首页 > 解决方案 > 如何解决:“无法将 'SelfieListViewController' 类型的值分配给类型 '(UIImagePickerControllerDelegate & UINavigationControllerDelegate)?'”

问题描述

我收到此错误:无法将类型“SelfieListViewController”的值分配给类型“(UIImagePickerControllerDelegate & UINavigationControllerDelegate)?”

对于此功能:

@objc func createNewSelfie()
    {
        //Create a new image picker
        let imagePicker = UIImagePickerController()

        //If a camera is a available, use it; otherwise, use the photo library
        if UIImagePickerController.isSourceTypeAvailable(.camera)
        {
            imagePicker.sourceType = .camera

            //If the front-facing camera is available, use that
            if UIImagePickerController.isCameraDeviceAvailable(.front)
            {
                imagePicker.cameraDevice = .front
            }
        }
        else
        {
            imagePicker.sourceType = .photoLibrary
        }

        //We want this object to be notified when the user takes a photo
        imagePicker.delegate = self

        //Present the image picker
        self.present(imagePicker, animated: true, completion: nil)
    }

标签: swift

解决方案


推荐阅读