如何在app控制器内打开相机。
我不想提出内置摄像头控制器 我想制作自己的相机应用程序。
任何建议或指南都将受到高度赞赏。
答案 0 :(得分:2)
您可以轻松地将UIImagePickerController
用于此
UIImagePickerController *imagePickerController;
@interface YourClassName : UIViewController <UINavigationControllerDelegate, UIImagePickerControllerDelegate>
imagePickerController = [[UIImagePickerController alloc] init];
[imagePickerController setDelegate:self];
[imagePickerController setSourceType:UIImagePickerControllerSourceTypeCamera];
[imagePickerController setMediaTypes:@"public.image"]]; //specify image (not video)
[imagePickerController setShowsCameraControls:NO]; //hide default camera controls
[imagePickerController setNavigationBarHidden:YES];
[imagePickerController setToolbarHidden:YES];
[imagePickerController setAllowsEditing:NO];
[self.view addSubview:imagePickerController.view];
对takePicture
对象使用UIImagePickerController
方法,并在按钮操作上分配,例如:
-(IBAction)btnTakePictureAct:(UIButton *)sender
{
[imagePickerController takePicture];
}
使用委托-imagePickerController:didFinishPickingMediaWithInfo:
获取图片。
-(void)imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary *)info
{
UIImage *image = info[UIImagePickerControllerOriginalImage];
}
看到这个,了解一下,制作自定义相机控件 请参阅:UIImagePickerController Apple Doc