简体   繁体   English

无法在我的应用程序中打开相机胶卷

[英]Camera Roll cannot be opened in my app

Camera Roll cannot be opened in my app. 无法在我的应用中打开“相机胶卷”。 In this controller, my goal is to select photos and send them to the server. 在此控制器中,我的目标是选择照片并将其发送到服务器。 PhotoController is like PhotoController就像

import Foundation
import UIKit
class PhotoController:UIViewController,UINavigationControllerDelegate,UIImagePickerControllerDelegate{
    @IBOutlet weak var myImageView: UIImageView!

    @IBAction func PhotoSelect(_ sender: Any) {
    }

    @IBAction func PhotoSend(_ sender: Any) {
        let myPickerController = UIImagePickerController()
        myPickerController.delegate = self;
        myPickerController.sourceType = UIImagePickerControllerSourceType.photoLibrary

        self.present(myPickerController, animated: true, completion: nil)
    }

      private func imagePickerController(picker: UIImagePickerController, didFinishPickingMediaWithInfo info: [String : AnyObject])

    {
        myImageView.image = info[UIImagePickerControllerOriginalImage] as? UIImage

        self.dismiss(animated: true, completion: nil)

    }
    override func viewDidLoad() {
        super.viewDidLoad()
        // Do any additional setup after loading the view, typically from a nib.

        //myImageUploadRequest()
    }
    override func didReceiveMemoryWarning() {
        super.didReceiveMemoryWarning()
        // Dispose of any resources that can be recreated.
    }

  }

Traceback is 追溯是

2017-06-12 14:04:43.054105 Kenshin_Swift[265:8781] Unknown class PhotoController in Interface Builder file. 2017-06-12 14:04:43.054105 Kenshin_Swift [265:8781] Interface Builder文件中的未知类PhotoController。 2017-06-12 14:04:46.320479 Kenshin_Swift[265:8781] -[UIViewController PhotoSelect:]: unrecognized selector sent to instance 0x100a0c9d0 2017-06-12 14:04:46.323252 Kenshin_Swift[265:8781] * Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[UIViewController PhotoSelect:]: unrecognized selector sent to instance 0x100a0c9d0' * First throw call stack: (0x184a211b8 0x18345855c 0x184a28268 0x184a25270 0x18491e80c 0x18a90bd30 0x18a90bcb0 0x18a8f6128 0x18a90b59c 0x18a90b0c4 0x18a906328 0x18a8d6da0 0x18b0c075c 0x18b0ba130 0x1849ceb5c 0x1849ce4a4 0x1849cc0a4 0x1848fa2b8 0x1863ae198 0x18a9417fc 0x18a93c534 0x1000f5274 0x1838dd5b8) libc++abi.dylib: terminating with uncaught exception of type NSException 2017-06-12 14:04:46.320479 Kenshin_Swift [265:8781]-[UIViewController PhotoSelect:]:无法识别的选择器已发送到实例0x100a0c9d0 2017-06-12 14:04:46.323252 Kenshin_Swift [265:8781] *由于以下原因终止了应用程序未捕获的异常'NSInvalidArgumentException',原因是: ' - [UIViewController中PhotoSelect:]:无法识别的选择发送到实例0x100a0c9d0' *第一掷调用堆栈:(0x184a211b8 0x18345855c 0x184a28268 0x184a25270 0x18491e80c 0x18a90bd30 0x18a90bcb0 0x18a8f6128 0x18a90b59c 0x18a90b0c4 0x18a906328 0x18a8d6da0 0x18b0c075c 0x18b0ba130 0x1849ceb5c 0x1849ce4a4 0x1849cc0a4 0x1848fa2b8 0x1863ae198 0x18a9417fc 0x18a93c534 0x1000f5274 0x1838dd5b8)libc ++ abi.dylib:以类型为NSException的未捕获异常终止

When I run my app on my real iPhone, my app stopped and this error happen. 当我在真实的iPhone上运行我的应用程序时,我的应用程序停止了,并发生了此错误。 error message 错误信息

I do not know why this error happen.Not codes but other setting is wrong, right?How can I fix this? 我不知道为什么会发生此错误。不是代码,而是其他设置错误,对吗?我该如何解决?

My info.plist is info.plist 我的info.plist是info.plist

I think you have not provide privacy security in your info.plist. 我认为您尚未在info.plist中提供隐私保护。

Privacy - Camera Usage Description -> for camera. 隐私-相机使用说明->相机。

Privacy - Photo Library Usage Description -> for photo library. 隐私-图片库使用说明->图片库。

if UIImagePickerController.isSourceTypeAvailable(UIImagePickerControllerSourceType.photoLibrary) {
       let imagePicker = UIImagePickerController()
       imagePicker.delegate = self
       imagePicker.sourceType = UIImagePickerControllerSourceType.photoLibrary
       self.present(imagePicker, animated: true, completion: nil)
 }

try this above code, if it does not work then check your IBAction PhotoSend Method outlet in Connection Inspector. 请尝试上面的代码,如果它不起作用,请在Connection Inspector中检查IBAction PhotoSend Method出口。

From the error traceback I believe the problem is with your IBAction Outlet @IBAction func PhotoSelect(_ sender: Any) . 从错误回溯中,我相信问题出在您的IBAction Outlet @IBAction func PhotoSelect(_ sender: Any) Please check the outlet for 请检查插座

 @IBAction func PhotoSelect(_ sender: Any) {
    }

in the interface builder and see whether you have added the outlet properly. 在界面构建器中,查看是否已正确添加插座。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 “打开方式”应在iPhone相机胶卷中显示我的应用 - “Open In” should show my app in iPhones Camera Roll 用户可以像使用本机胶卷应用程序一样通过Safari将图像保存到我的应用程序吗? - Is there any way a user could save images to my app from safari as they can do with the native camera roll app? 无法将CIImage保存到相机胶卷-Swift 3 - Cannot save CIImage to camera roll - Swift 3 无法将Instagram视频下载到相机胶卷 - Cannot download Instagram video to camera roll 我可以在相机胶卷上获取视频的绝对 URI 并从我的应用程序中对其进行变异吗? - Can I get absolute URI of video on camera roll and mutate it from my app? 在Twitter App中显示相机胶卷? - Display Camera Roll like in the Twitter App? 我删除了我应用中的视频,但该视频仍然存在于相机胶卷中,反之亦然 - I delete a video in my app, but it still exists in the camera roll and vice versa 视频应用程序将.mp4保存到相机胶卷 - video app save .mp4 to camera roll “相机胶卷”和“我的照片流”的PHAssetCollection为空 - PHAssetCollection for “Camera Roll” and “My Photo Stream” is empty 如何从相机胶卷中选择图片,然后将其保存到应用程序的“ Supporting Files”文件夹中,然后选择已保存文件的名称? - How can I select a picture from the camera roll, then save it to the “Supporting Files” folder of my app, then pick up the name of the saved file?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM