繁体   English   中英

UIImagePickerController takePicture方法

[英]UIImagePickerController takePicture method

目标:在其他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;

但这只是一个猜测。

暂无
暂无

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

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