我在iOS 7中测试新的条形码扫描api时出了问题.这个例子(单视图应用程序)工作正常,但我想停止AVCaptureSession并在摄像机识别出EAN代码后显示第一个视图.
[self.captureSession startRunning]; 不起作用.
我如何正确停止AVCaptureSession?
#import "ViewController.h"
#import <AVFoundation/AVFoundation.h>
@interface ViewController () <AVCaptureMetadataOutputObjectsDelegate>
@property (strong) AVCaptureSession *captureSession;
@end
@implementation ViewController
- (void)viewDidLoad
{
[super viewDidLoad];
self.captureSession = [[AVCaptureSession alloc] init];
AVCaptureDevice *videoCaptureDevice = [AVCaptureDevice defaultDeviceWithMediaType:AVMediaTypeVideo];
NSError *error = nil;
AVCaptureDeviceInput *videoInput = [AVCaptureDeviceInput deviceInputWithDevice:videoCaptureDevice error:&error];
if(videoInput)
[self.captureSession addInput:videoInput];
else
NSLog(@"Error: %@", error);
AVCaptureMetadataOutput *metadataOutput = [[AVCaptureMetadataOutput alloc] init];
[self.captureSession addOutput:metadataOutput];
[metadataOutput setMetadataObjectsDelegate:self queue:dispatch_get_main_queue()];
[metadataOutput setMetadataObjectTypes:@[AVMetadataObjectTypeQRCode, AVMetadataObjectTypeEAN13Code]];
AVCaptureVideoPreviewLayer *previewLayer = [[AVCaptureVideoPreviewLayer alloc] initWithSession:self.captureSession];
previewLayer.frame = self.view.layer.bounds;
[self.view.layer addSublayer:previewLayer];
[self.captureSession startRunning]; …Run Code Online (Sandbox Code Playgroud) 我需要以编程方式备份所有记录(数字,名称,图像......)的所有联系人.我读到了关于AddressBook.framework的内容,但有一种简单的方法来备份所有联系人吗?