二维码---相册识别 swift

二维码---相册识别 swift,第1张

概述swift 3.0 xcode 8.1 需要在info.plist 添加 Privacy - Photo Library Usage Description YES import UIKitclass ViewController: UIViewController, UIImagePickerControllerDelegate, UINavigationControllerDelegate swift 3.0 xcode 8.1 需要在info.pList 添加 Privacy - Photo library Usage Description YES@H_301_3@
import UIKitclass VIEwController: UIVIEwController,UIImagePickerControllerDelegate,UINavigationControllerDelegate {    overrIDe func vIEwDIDLoad() {        super.vIEwDIDLoad()                let button = UIbutton.init(type: UIbuttonType.custom)        button.frame = CGRect.init(x: 20,y: 300,wIDth: 300,height: 40)        button.setTitle("点击获取相册二维码图片信息",for: UIControlState.normal)        button.setTitlecolor(UIcolor.black,for: UIControlState.normal)        button.addTarget(self,action: #selector(self.getimage),for: UIControlEvents.touchUpInsIDe)        self.vIEw.addSubvIEw(button)     }            func getimage() {                let imagePickCST = UIImagePickerControllerSourceType.photolibrary        let imagePickC = UIImagePickerController.init()        imagePickC.sourceType = imagePickCST        imagePickC.delegate = self        self.present(imagePickC,animated: true,completion: nil)            }        func imagePickerController(_ picker: UIImagePickerController,dIDFinishPickingMediawithInfo info: [String : Any]) {                picker.dismiss(animated: true,completion: nil)                //获取到的原始图片        let image = info[UIImagePickerControllerOriginalimage]                let imageData = UIImagePNGRepresentation(image as! UIImage)        let ciImage = CIImage(data: imageData!)                //初始化一个检测器        let detector = CIDetector(ofType: CIDetectorTypeQRCode,context: nil,options: [CIDetectorAccuracy:CIDetectorAccuracyLow])                //检测到的结果数组        let array = detector?.features(in: ciImage!)                //取出数组中的第一个结果        if (array?.count)! > 0 {            let result: CiqrCodeFeature = array!.first as! CiqrCodeFeature            print(result.messageString!)        }            }            overrIDe func dIDReceiveMemoryWarning() {        super.dIDReceiveMemoryWarning()        // dispose of any resources that can be recreated.    }}
总结

以上是内存溢出为你收集整理的二维码---相册识别 swift全部内容,希望文章能够帮你解决二维码---相册识别 swift所遇到的程序开发问题。

如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。

欢迎分享,转载请注明来源:内存溢出

原文地址:https://54852.com/web/1069481.html

(0)
打赏 微信扫一扫微信扫一扫 支付宝扫一扫支付宝扫一扫
上一篇 2022-05-26
下一篇2022-05-26

发表评论

登录后才能评论

评论列表(0条)

    保存