Swift快速集成函数使用(相机选择或相册选择)

  • 1 先看看我们的gif


    Camera.gif

一行代码集成 该类函数必须是继承 UIViewController

//方式一
 CommonFunction.CameraPhotoAlertController(self) { (img) in
           print(img)
       }
//方式二
       self.ShowCameraPhotoSheet { (value) in
             print(value)
       }

如果想重写相机选中后的图片处理,可以重写已拓展好的类
我们看看 UIViewController 已经做好了相机的拓展

extension UIViewController:SKStoreProductViewControllerDelegate,UIImagePickerControllerDelegate, UINavigationControllerDelegate

如果需要重写“相机”或"取消",代码如下:

    
    //相机选择图片后
    override func imagePickerController(picker: UIImagePickerController, didFinishPickingMediaWithInfo info: [String : AnyObject]) {
        
    }
    //选择取消
     override func imagePickerControllerDidCancel(picker: UIImagePickerController) {
        picker.dismissViewControllerAnimated(true, completion: nil)
    }

如需代码,请移动到--->http://www.jianshu.com/p/0f950c180cb8

最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容