Ios 线程1:断点3.1错误

Ios 线程1:断点3.1错误,ios,iphone,swift,xcode,Ios,Iphone,Swift,Xcode,线程1:发生断点3.1错误。 我正在制作一个可以访问相机和照片库的应用程序,我可以在我的应用程序中上传照片。我从Xcode在真正的iPhone上运行我的应用程序。 当我放置ButtonCamera时,这个错误发生在这个部分 if sender.tag == ButtonCamera { 控制器就像 import UIKit class KenshinSendController:UIViewController, UINavigationControllerDelegate,UIImag

线程1:发生断点3.1错误。 我正在制作一个可以访问相机和照片库的应用程序,我可以在我的应用程序中上传照片。我从Xcode在真正的iPhone上运行我的应用程序。 当我放置ButtonCamera时,这个错误发生在这个部分

if sender.tag == ButtonCamera {  
控制器就像

import UIKit

class KenshinSendController:UIViewController,
UINavigationControllerDelegate,UIImagePickerControllerDelegate{

    //定数
    let ButtonCamera = 0
    let ButtomRead = 1
    let ButtonWrite = 2

    //変数
    var imageView:UIImageView  = UIImageView()
    var btnCamera:UIButton = UIButton(type: .custom)
    var btnRead:UIButton  = UIButton(type: .custom)
    var btnWrite:UIButton  = UIButton(type: .custom)




    //ロード完了時に呼ばれる
    override func viewDidLoad() {
        super.viewDidLoad()
        imageView.frame = CGRect(x: 150, y: 100, width: 200, height: 200)
        imageView.contentMode = .scaleAspectFit
        view.addSubview(imageView)

        btnCamera.frame = CGRect(x: 0, y: 100, width: 100, height: 100)
        btnCamera.setTitle("Camera", for: .normal)
        btnCamera.tag = ButtonCamera
        btnCamera.addTarget(self, action: #selector(self.onClick(sender:)), for: .touchUpInside)
        btnCamera.backgroundColor = UIColor.green
        self.view.addSubview(btnCamera)

        btnRead.frame = CGRect(x: 0, y: 200, width: 100, height: 100)
        btnRead.setTitle("Read", for: .normal)
        btnRead.tag = ButtomRead
        btnRead.addTarget(self, action: #selector(self.onClick(sender:)), for: .touchUpInside)
        btnRead.backgroundColor = UIColor.red
        self.view.addSubview(btnRead)

        btnWrite.frame = CGRect(x: 0, y: 300, width: 100, height: 100)
        btnWrite.setTitle("Write", for: .normal)
        btnWrite.tag = ButtonWrite
        btnWrite.addTarget(self, action: #selector(self.onClick(sender:)), for: .touchUpInside)
        btnWrite.backgroundColor = UIColor.blue
        self.view.addSubview(btnWrite)
    }

    //ボタンクリック時に呼ばれる
    @IBAction func ButtonCamera(_ sender: Any) {
    }
    @IBAction func ButtonRead(_ sender: Any) {
    }
    func onClick(sender:UIButton){
       if sender.tag == ButtonCamera {
          openPicker(sourceType: UIImagePickerControllerSourceType.camera)
       }else if sender.tag == ButtomRead {
           openPicker(sourceType: UIImagePickerControllerSourceType.photoLibrary)
        }

    }

    //アラートの表示
    func showAlert(title: String?, text: String?) {
        let alert = UIAlertController(title: title, message: text, preferredStyle: UIAlertControllerStyle.alert)
        alert.addAction(UIAlertAction(title: "OK", style: UIAlertActionStyle.default, handler: nil))
        present(alert, animated: true, completion: nil)
    }

  //イメージピッカーのオープン
    func openPicker(sourceType:UIImagePickerControllerSourceType){
        if !UIImagePickerController.isSourceTypeAvailable(sourceType){
            showAlert(title: nil, text: "利用できません")
            return
        }

        //イメージピッカーの生成
        let picker = UIImagePickerController()
        picker.sourceType = sourceType
        picker.delegate = self

        //ビューコントローラーのビューを開く
        present(picker, animated: true, completion: nil)
           }

    func imagePickerController(_ picker: UIImagePickerController, didFinishPickingMediaWithInfo info: [String : Any]) {
        let image = info[UIImagePickerControllerOriginalImage]as! UIImage
        imageView.image = image
        //ビューコントローラーのビューを閉じる
        picker.presentingViewController?.dismiss(animated: true,completion:nil)
    }

    func imagePickerControllerDidCancel(_ picker: UIImagePickerController) {
        picker.presentingViewController?.dismiss(animated: true, completion: nil)
    }

}
按钮设置就像

控制器设置如下

plist就像

<plist version="1.0">
<dict>
    <key>UILaunchStoryboardName</key>
    <string></string>
    <key>CFBundleGetInfoString</key>
    <string></string>
    <key>NSPhotoLibraryUsageDescription</key>
    <string>フォトライブラリの使用許可をお願いします</string>
    <key>CFBundleDisplayName</key>
    <string></string>
    <key>NSCameraUsageDescription</key>
    <string>カメラの使用許可をお願いします</string>
    <key>LSApplicationCategoryType</key>
    <string></string>
    <key>CFBundleDevelopmentRegion</key>
    <string>en</string>
    <key>CFBundleExecutable</key>
    <string>$(EXECUTABLE_NAME)</string>
    <key>CFBundleIdentifier</key>
    <string>$(PRODUCT_BUNDLE_IDENTIFIER)</string>
    <key>CFBundleInfoDictionaryVersion</key>
    <string>6.0</string>
    <key>CFBundleName</key>
    <string>$(PRODUCT_NAME)</string>
    <key>CFBundlePackageType</key>
    <string>APPL</string>
    <key>CFBundleShortVersionString</key>
    <string>1.0</string>
    <key>CFBundleVersion</key>
    <string>1</string>
    <key>LSRequiresIPhoneOS</key>
    <true/>
    <key>UIMainStoryboardFile</key>
    <string>Main</string>
    <key>UIRequiredDeviceCapabilities</key>
    <array>
        <string>armv7</string>
    </array>
    <key>UISupportedInterfaceOrientations</key>
    <array>
        <string>UIInterfaceOrientationPortrait</string>
        <string>UIInterfaceOrientationLandscapeLeft</string>
        <string>UIInterfaceOrientationLandscapeRight</string>
    </array>
    <key>UISupportedInterfaceOrientations~ipad</key>
    <array>
        <string>UIInterfaceOrientationPortrait</string>
        <string>UIInterfaceOrientationPortraitUpsideDown</string>
        <string>UIInterfaceOrientationLandscapeLeft</string>
        <string>UIInterfaceOrientationLandscapeRight</string>
    </array>
</dict>
</plist>

UILaunchStoryboardName
cfbundlegetingfostring
NSPhotoLibraryUsageDescription
フォトライブラリの使用許可をお願いします
CbundleDisplayName
NSCameraUsageDescription
カメラの使用許可をお願いします
LSApplicationCategoryType
CfBundledDevelopmentRegion
EN
Cbundlexecutable
$(可执行文件名称)
CbundleIdentifier
$(产品\捆绑包\标识符)
CbundleInfo字典版本
6
CFBundleName
$(产品名称)
CbundlePackageType
应用
CbundleShortVersionString
1
循环流化床锅炉
1.
LSREQUIRESPHONEOS
UIMainstryBoardFile
主要
UIRequiredDeviceCapabilities
armv7
UI支持接口方向
UIInterfaceOrientationPortrait
UIInterface方向和左视图
UIInterfaceOrientationAndscapeRight
UI支持界面方向~ipad
UIInterfaceOrientationPortrait
UIInterfaceOrientation上下方向图
UIInterface方向和左视图
UIInterfaceOrientationAndscapeRight
我该怎么做才能修好它