美文网首页
swift引用oc类 在swift文件里如何给oc类的block

swift引用oc类 在swift文件里如何给oc类的block

作者: 他们撑起了农忙双抢 | 来源:发表于2017-10-25 19:54 被阅读6次
    有参数,无返回值

    let controller =UIImagePickerController.init()

    if index == 0 {

        controller.sourceType= .camera

    } else {

        controller.sourceType= .photoLibrary

    }

    // default value is an array containing kUTTypeImage.文档说明默认值是此,故不需设置

    // controller.mediaTypes = [kUTTypeImage]

    controller.cropSize = CGSize(width: 300, height: 300)

    controller.cropMode = .square//DZNPhotoEditorViewControllerCropModeSquare

    controller.finalizationBlock = { [weak self] picker, info -> Void in

            QLDebug(picker)

            QLDebug(info)

            if let strongSelf = self {

               var image :UIImage? = nil

                if strongSelf.needEdit {

                     image = info?[UIImagePickerControllerEditedImage] as? UIImage

                } else {

                     image = info?[UIImagePickerControllerOriginalImage]as?UIImage

                }

                image = image?.fixOrientation()

                if let myImage = image {

                   // 拿到image保存起来

                   strongSelf.addImageButton.setBackgroundImage(myImage, for: .normal)

                   strongSelf.setTupleOfSomeone(number:8, value: image)

                   QLDebug(myImage)

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

                }

            }

    }

    controller.cancellationBlock = { [weak self] picker in

           QLDebug(picker?.viewControllers)

           if let strongSelf = self {

               if picker?.viewControllers.count == 1 {

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

               } else {

                    picker?.popViewController(animated: true)

               }

           }

    }      

           //UIApplication.shared.statusBarStyle = .default

           self.statusBarColor=KFXStatusBarColor.black

           self.present(controller, animated: true, completion: nil)

    }

    相关文章

      网友评论

          本文标题:swift引用oc类 在swift文件里如何给oc类的block

          本文链接:https://www.haomeiwen.com/subject/nmdcpxtx.html