Problem
I have an example application from Apple (SquareCam) , which I use as a link to create a user interface for the camera. I am using the AVFoundation framework. If I create and run a project from Apple, the application works as expected. However, if I take the same code from this project and put it in a new project in Xcode, the video preview will not be displayed.
I simplified the code to the main components in order to run the video preview layer. Again, this code works fine, as in the Apple project (SquareCam), but does not appear in my new project.
The code
- (void)setupAVCapture { NSError *error = nil; AVCaptureSession *session = [AVCaptureSession new]; if ([[UIDevice currentDevice] userInterfaceIdiom] == UIUserInterfaceIdiomPhone) [session setSessionPreset:AVCaptureSessionPreset640x480]; else [session setSessionPreset:AVCaptureSessionPresetPhoto];
What have i tried?
I have all the correct settings. I have all the framework libraries in my build phase. Both projects use storyboards. What is strange is that I can capture the image from the camera and even switch the source from front to back. But the preview will not be displayed. Apple project has not been configured using ARC. So, I updated the project to use ARC. Again, it works great in an Apple project, but not in a new project.
Thoughts?
Any ideas on what could be the problem? Could this be the reason for this project?
ios objective-c xcode video avfoundation
Corey
source share