[英]How to open camera in small region of view in ios
我必须在应用程序的小屏幕区域中打开摄像头,但由于通常会在全屏模式下打开摄像头,因此无法实现它。
相机应该在uiimage视图区域中打开,请Plz指导我如何实现。谢谢。
您应该看一下Apple提供的AVCam示例项目。 它具有您执行任务所需的所有功能。 祝好运!
我试验了上一篇文章中的代码,并注释了最终的比例转换((使它变为全尺寸的)),最后我得到了一个可爱的微型相机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];
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.