Latest 1.0.2
Homepage https://github.com/a334713698/HDJCameraViewController
License MIT
Platforms ios
Frameworks AVFoundation
Authors

HDJCameraViewController——仿微信相机

使用方法

0.导入系统库

    AVFoundation.framework

1.创建并进入相机控制器

    HDJCameraViewController* next = [HDJCameraViewController new];
    next.timeLimit = 10;//视频的拍摄时长限制。不填或默认为10秒
    next.delegate = self;//设置代理,用于获取媒体的回调
    next.saveMediaIntoAlbum = NO;//是否保存拍摄结果。默认:不保存
    [self presentViewController:next animated:YES completion:nil];

2.遵守delegate代理协议

    <HDJCameraViewControllerDelegate>

3.实现代理方法

- (void)cameraViewController:(HDJCameraViewController *)camera didFinishMediaWithType:(HDJMediaType)mediaType withInfo:(NSDictionary<NSString *,id> *)info{
    //mediaType:返回的媒体类型。
    //info:媒介,通过key值,获取所需要的媒体。
    UIImage* image = info[HDJCameraViewControllerImage];
    self.imageView.image = image;
    if (mediaType == HDJMediaTypeVideo) {
        NSLog(@"返回视频所在的沙盒路径:%@",info[HDJCameraViewControllerVideoURL]);
    }
}

安装

Use CocoaPods

    pod 'HDJCameraViewController'

可能出现的问题及解决办法

编译报错:Cannot synthesize weak property because the current deployment target does not support weak references

  • 解决办法一(推荐):集成项目后,可能需要手动更新设置(处理系统报警告:⚠️validate project settings)
  • 解决办法二:将Build Settings –> iOS Deployment Target 改为 iOS 9.0(支持的最低iOS版本)
  • 解决办法三:手动导入支持文件

注意事项

需要在info.plist文件中设置用户隐私访问权限

  • NSPhotoLibraryUsageDescription : 相册权限
  • NSCameraUsageDescription : 相机权限
  • NSMicrophoneUsageDescription : 麦克风权限

参考项目

Latest podspec

{
    "name": "HDJCameraViewController",
    "version": "1.0.2",
    "platforms": {
        "ios": null
    },
    "summary": "HDJCameraViewController u2014u2014 u4effu5faeu4fe1u76f8u673a",
    "homepage": "https://github.com/a334713698/HDJCameraViewController",
    "license": "MIT",
    "authors": {
        "u6d2au51acu4ecb": "[email protected]"
    },
    "social_media_url": "https://weibo.com/1871979715",
    "source": {
        "git": "https://github.com/a334713698/HDJCameraViewController.git",
        "tag": "1.0.2"
    },
    "source_files": [
        "HDJCameraViewController/*",
        "HDJCameraViewController/**/*"
    ],
    "frameworks": "AVFoundation"
}

Pin It on Pinterest

Share This