zoukankan      html  css  js  c++  java
  • [翻译] LLSimpleCamera

    LLSimpleCamera A simple customizable camera control

    LLSimpleCamera is a library for creating a customized camera screens similar to snapchat's. You don't have to present the camera in a new view controller.

    LLSimpleCamera是一个开源库,帮助你创建自定义的照相机,类似于应用snapchat那样子的效果。你不需要重新在新控制器中创建出照相机。

    LLSimpleCamera:

    • lets you easily capture photos 能让你非常容易的截取图片
    • handles the position and flash of the camera 能控制照相机的位置以及照相机闪光灯
    • hides the nitty gritty details from the developer 隐藏各种恶心的代码细节
    • don't have to be presented in a new modal view controller, simply can be embedded any of your VCs. (like Snapchat) 可以快速的嵌入到你的控制器当中

    Version 1.1.1

    • fixed a potential crash scenario if -stop() is called multiple times 修复了一个重复调用-stop()导致崩溃的问题

    Version 1.1.0

    • fixed a problem that sometimes caused a crash after capturing a photo. 修复了有时候获取图片时崩溃的问题
    • improved code structure, didChangeDevice delegate is now also triggered for the first default device.  改进代码结构,didChangeDevice代理方法如今已经可以控制第一个默认的设备了

    Install

    pod 'LLSimpleCamera', '~> 1.1'

    Example usage - 如何使用

    CGRect screenRect = [[UIScreen mainScreen] bounds];
    
    // create camera vc
    self.camera = [[LLSimpleCamera alloc] initWithQuality:CameraQualityPhoto];
    
    // attach to the view and assign a delegate
    [self.camera attachToViewController:self withDelegate:self];
    
    // set the camera view frame to size and origin required for your app
    self.camera.view.frame = CGRectMake(0, 0, screenRect.size.width, screenRect.size.height);
    

    and here are the example delegates:

    这是代理的使用方式:

    /* camera delegates */
    - (void)cameraViewController:(LLSimpleCamera *)cameraVC didCaptureImage:(UIImage *)image {
    
        // we should stop the camera, since we don't need it anymore. We will open a new vc.
        [self.camera stop];
    
        ImageViewController *imageVC = [[ImageViewController alloc] initWithImage:image];
        [self presentViewController:imageVC animated:NO completion:nil];
    }
    
    - (void)cameraViewController:(LLSimpleCamera *)cameraVC didChangeDevice:(AVCaptureDevice *)device {
    
        // device changed, check if flash is available
        if(cameraVC.isFlashAvailable) {
            self.flashButton.hidden = NO;
        }
        else {
            self.flashButton.hidden = YES;
        }
    
        self.flashButton.selected = NO;
    }
    

    Adding the camera controls - 添加照相机控制

    You have to add your own camera controls (flash, camera switch etc). Simply add the controls to the view that the camera is attached to. You can see a full camera example in the example project. Download and try it on your device.

    你需要添加你自己的照相机控制(闪光灯,照相机等等诸如此类的)。你只需要简单的将控制相关的控件添加上去就可以,你可以在示例代码中看一下就知道了。

    Stopping and restarting the camera

    You should never forget to stop the camera either after the didCaptureImage delegate is triggered, or inside somewhere -viewWillDisappear of the parent controller to make sure your app doesn't try to use the camera when it is not needed. You can call -start() again to use the camera. So it may be good idea to to place -start() inside -viewWillAppear or some other method where you think it's good to start using the camera input.

    你永远都不应该忘记不用的时候要调用didCaptureImage,或者在其他地方调用-viewWillDisappear。你可以在需要用的时候重新执行-start(),所以,比较便利的方法,就是你将-start()方法放到-viewWillAppear,或者其他的方法当中,你觉得方便就行。

  • 相关阅读:
    phone8 inapp purchasing
    Delegate,Action,Func,匿名方法,匿名委托,事件
    get a full screen popup to work on WP8
    as3.0动态文本大全
    actionScript 3 殿堂之路 第四章 学习收获
    java中的switch case
    Silverlight的DataGrid导出文档
    ArcGIS教程大全
    同步异步请求区别
    XML操作,XPath语法
  • 原文地址:https://www.cnblogs.com/YouXianMing/p/4205241.html
Copyright © 2011-2022 走看看