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;
但这只是一个猜测。     

要回复问题请先登录注册