我疯狂地想要在我的项目中呈现和解散AVCaptureSession(在视图控制器中).我目前在iOS5.1上并启用了ARC.
我第一次出现viewcontroller并开始会话时可以正常工作但是当我解雇并再次出现时会话将无法启动.我订阅了"AVCaptureSessionRuntimeErrorNotification"通知并收到以下错误:
"错误域= AVFoundationErrorDomain代码= -11819"无法完成操作"UserInfo = 0x1a4020 {NSLocalizedRecoverySuggestion =稍后再试.,NSLocalizedDescription =无法完成操作}"
我假设在我的会话中没有正确发布某些内容,但是ARC没有发布,而是我将所有内容都设置为nil.
我的viewDidLoad方法基本上只是触发initCamera
initCamera方法:
AVCaptureSession *tmpSession = [[AVCaptureSession alloc] init];
session = tmpSession;
session.sessionPreset = AVCaptureSessionPresetMedium;
captureVideoPreviewLayer = [[AVCaptureVideoPreviewLayer alloc] initWithSession:session];
captureVideoPreviewLayer.frame = self.vImagePreview.bounds;
[self.vImagePreview.layer addSublayer:captureVideoPreviewLayer];
rearCamera = [AVCaptureDevice defaultDeviceWithMediaType:AVMediaTypeVideo];
NSError *error = nil;
input = [AVCaptureDeviceInput deviceInputWithDevice:rearCamera error:&error];
if (!input) {
// Handle the error appropriately.
NSLog(@"ERROR: trying to open camera: %@", error);
}
[session addInput:input];
videoDataOutput = [[AVCaptureVideoDataOutput alloc] init];
NSDictionary *outputSettings = [[NSDictionary alloc] initWithObjectsAndKeys: [NSNumber numberWithInt:kCVPixelFormatType_32BGRA], kCVPixelBufferPixelFormatTypeKey, …Run Code Online (Sandbox Code Playgroud) modalviewcontroller ios avcapturesession automatic-ref-counting
我不知道为什么这个非常基本的代码设置空值.
NSDate *currentTime = [NSDate date];
[datePicker setMinimumDate:currentTime];
[datePicker setMaximumDate:[currentTime dateByAddingTimeInterval:kSecondsInYear]];
NSLog(@"cur: %@, min: %@, max: %@",currentTime,datePicker.minimumDate,datePicker.maximumDate);
Run Code Online (Sandbox Code Playgroud)
输出:cur:2011-09-09 16:18:18 GMT,min:(null),max:(null)