So, I had this code working on my other application for taking photos on a custom camera view, when I had iOS 7 on my phone and Xcode 5.1, now on iOS 8 and Xcode 6 the camera works, but I canβt see. Live image of the camera in the left Vertical UIView. Here is my code, I would appreciate any help Thank you!
#import <AVFoundation/AVFoundation.h> session = [[AVCaptureSession alloc] init]; if ([[UIDevice currentDevice] userInterfaceIdiom] == UIUserInterfaceIdiomPhone) [session setSessionPreset:AVCaptureSessionPreset352x288]; else [session setSessionPreset:AVCaptureSessionPreset352x288]; AVCaptureDevice *inputDevice = [AVCaptureDevice defaultDeviceWithMediaType:AVMediaTypeVideo]; NSError *error; AVCaptureDeviceInput *deviceInput = [AVCaptureDeviceInput deviceInputWithDevice:inputDevice error:&error]; if ([session canAddInput:deviceInput]) { [session addInput:deviceInput]; } AVCaptureVideoPreviewLayer *previewLayer = [[AVCaptureVideoPreviewLayer alloc] initWithSession:session]; [previewLayer setVideoGravity:AVLayerVideoGravityResizeAspectFill]; CALayer *rootLayer = [[self view] layer]; [rootLayer setMasksToBounds:YES]; CGRect frame = self.leftVertical.frame; [previewLayer setFrame:frame]; [rootLayer insertSublayer:previewLayer atIndex:0]; ////////////////////////// stillImageOutput = [[AVCaptureStillImageOutput alloc] init]; NSDictionary *outputSettings = [[NSDictionary alloc] initWithObjectsAndKeys:AVVideoCodecJPEG, AVVideoCodecKey, nil]; [stillImageOutput setOutputSettings:outputSettings]; [session addOutput:stillImageOutput]; [session startRunning];
source share