如何解决UIImagePickerController takePicture方法
| 目标:在其他GUI运行时以静音模式拍照。 作业系统:IOS 4.3 我正在做一个测试,我想在执行ViewDidLoad时以静默方式拍摄一张图像: 我不想要任何相机gui ...让我知道你的想法.. 观察UIImagePickerController,我看到我可以分配一些属性并执行takePicture方法..最重要的是,尝试执行该操作时什么也没有发生,我看到了几KB ..这表明您必须等待..所以我确实使睡眠(10)但没有帮助。 也许我在某处缺少代表,而我读到代表不是必须的。 有什么想法吗? 这是代码: 头文件:#import <UIKit/UIKit.h>
#import <Foundation/Foundation.h>
@interface VisionViewController : UIViewController
{
UIImagePickerController *controller;
}
-(void)settingControllerAndTakingPicture;
@end
和实施文件
//加载视图后,通常通过笔尖实现viewDidLoad进行其他设置。
-(void)viewDidLoad
{
[super viewDidLoad];
//Taking an Image
[self settingControllerAndTakingPicture ];
}
-(void)settingControllerAndTakingPicture
{
controller = [[UIImagePickerController alloc] init];
//Setting the control source type as the Camera device.
controller.sourceType = UIImagePickerControllerSourceTypeCamera;
//Camera display is off,the player will not see it during games.
controller.showsCameraControls = NO;
//Picking only the front camera.
controller.cameraDevice = UIImagePickerControllerCameraDeviceFront;
//Turning the camera flash off.
controller.cameraFlashMode = UIImagePickerControllerCameraFlashModeOn;
//Setting the controller view as self view
controller.view = self.view;
//Taking a picture
[controller takePicture];
}
同样,我只在静音模式下很有趣。
解决方法
您尚未将UIImagePickerController添加到视图层次结构,直到您将其实例化为止。您需要presentModalViewController或类似的东西。
另外我不认为更改controller.view会像您希望的那样工作,我认为您可能必须使用:
controller.showsCameraControls = NO;
controller.cameraOverlayView = self.view;
但这只是一个猜测。
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。