iOS应用程序中的摄像头教程
我想知道是否有人愿意分享如何在iOS应用程序中加入摄像头功能,或者是否有人知道一个简单的教程。没有任何按钮,只是在屏幕上显示相机看到的东西。我尝试了苹果的文档,但它对我的需求来说太复杂了 非常感谢你iOS应用程序中的摄像头教程,ios,camera,Ios,Camera,我想知道是否有人愿意分享如何在iOS应用程序中加入摄像头功能,或者是否有人知道一个简单的教程。没有任何按钮,只是在屏幕上显示相机看到的东西。我尝试了苹果的文档,但它对我的需求来说太复杂了 非常感谢你 编辑:任何简单的教程都可以。就像我说的,我不需要任何其他东西,除了它来显示相机看到的东西。我不知道简单的教程,但是添加一个显示相机看到的东西的视图非常简单 第一名: 将UIView添加到将显示相机的界面生成器中 秒: 将AVFoundation framework添加到项目中,并将其导入到ViewC
编辑:任何简单的教程都可以。就像我说的,我不需要任何其他东西,除了它来显示相机看到的东西。我不知道简单的教程,但是添加一个显示相机看到的东西的视图非常简单 第一名: 将UIView添加到将显示相机的界面生成器中 秒: 将AVFoundation framework添加到项目中,并将其导入到ViewController.m文件中
#import <AVFoundation/AVFoundation.h>
第四名:
将此代码添加到viewDidLoad。(对其作用的解释已注释)
注意事项:
这不是我需要的。我希望我的应用程序没有任何按钮@我读了它。“您可以使用
[myImagePickerController setShowsCameraControls:NO];
隐藏UIImagePickerController的控件。
。还有一个:。在发布之前最好在上面搜索所需内容;)第二个很好,但在编辑器中我得到了错误未知类型名称“myImagePicker”“当我将代码放入Xcode时。我该如何解决这个问题。另外,如何将此代码连接到我的xib@来自苹果的R3MuaseAV基础示例:如何使用这个自定义相机拍摄照片?您使用具有此签名的方法:-(空)CoptuSrimLimaGaseAccess同步从连接:(AvCaseCuthOut连接*)连接CuleTythHANDLANER:(空隙(^)(CMSampleBufferRef imageDataSampleBuffer,nSerror *错误))处理程序;
AVCaptureVideoPreviewLayer *_previewLayer;
AVCaptureSession *_captureSession;
//-- Setup Capture Session.
_captureSession = [[AVCaptureSession alloc] init];
//-- Creata a video device and input from that Device. Add the input to the capture session.
AVCaptureDevice * videoDevice = [AVCaptureDevice defaultDeviceWithMediaType:AVMediaTypeVideo];
if(videoDevice == nil)
assert(0);
//-- Add the device to the session.
NSError *error;
AVCaptureDeviceInput *input = [AVCaptureDeviceInput deviceInputWithDevice:videoDevice
error:&error];
if(error)
assert(0);
[_captureSession addInput:input];
//-- Configure the preview layer
_previewLayer = [[AVCaptureVideoPreviewLayer alloc] initWithSession:_captureSession];
_previewLayer.videoGravity = AVLayerVideoGravityResizeAspectFill;
[_previewLayer setFrame:CGRectMake(0, 0,
self.cameraPreviewView.frame.size.width,
self.cameraPreviewView.frame.size.height)];
//-- Add the layer to the view that should display the camera input
[self.cameraPreviewView.layer addSublayer:_previewLayer];
//-- Start the camera
[_captureSession startRunning];