简体   繁体   English

如何在iOS的小视野内打开相机

[英]How to open camera in small region of view in ios

I have to open camera in my app in small region of screen ,but not getting how to implement it,because camera opens on full screen genreally. 我必须在应用程序的小屏幕区域中打开摄像头,但由于通常会在全屏模式下打开摄像头,因此无法实现它。 在此处输入图片说明

The camera should be open in uiimage view region,Plz guide me how to achieve this.Thanks. 相机应该在uiimage视图区域中打开,请Plz指导我如何实现。谢谢。

You should take a look at AVCam sample project provided by Apple. 您应该看一下Apple提供的AVCam示例项目。 It has all the features you need for your task. 它具有您执行任务所需的所有功能。 Good Luck! 祝好运!

I experimented with the code from my last post, and commented out the final scale transform ((the one which makes it full size) and I ended up with a lovely miniature camera imagePicker floating in the middle of my screen, so it definitely does work! The exact code I used, including the zoom/fade-in transition, is - 我试验了上一篇文章中的代码,并注释了最终的比例转换((使它变为全尺寸的)),最后我得到了一个可爱的微型相机imagePicker,它悬浮在屏幕中间,因此它确实可以工作!我使用的确切代码(包括缩放/淡入过渡)是-

UIImagePickerController *imagePickerController = [[UIImagePickerController alloc] init];

imagePickerController.delegate = self;
imagePickerController.mediaTypes = [NSArray arrayWithObjects:(NSString *)kUTTypeImage, nil];
imagePickerController.sourceType = UIImagePickerControllerSourceTypeCamera;
imagePickerController.cameraCaptureMode = UIImagePickerControllerCameraCaptureModePhoto;

UIView *controllerView = imagePickerController.view;

controllerView.alpha = 0.0;
controllerView.transform = CGAffineTransformMakeScale(0.5, 0.5);

[[[[UIApplication sharedApplication] delegate] window] addSubview:controllerView];

[UIView animateWithDuration:0.3
              delay:0.0
            options:UIViewAnimationOptionCurveLinear
         animations:^{
             controllerView.alpha = 1.0;
         }
         completion:nil
];

[imagePickerController release];

you can go through my answer here. 您可以在这里查看我的答案

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM