【发布时间】:2011-08-05 00:18:30
【问题描述】:
目标:在其他 GUI 运行时以静音模式拍照。
操作系统:IOS 4.3
我在做一个测试,我想在执行 ViewDidLoad 时以静默模式拍摄一张图像: 我不想要任何相机 gui...让我知道您的想法..
观察 UIImagePickerController 我发现我可以分配一些属性并执行 takePicture 方法.. 底线是尝试执行它时没有发生任何事情,我看到几个 KB.. 这告诉你必须等待.. 所以我确实放了 sleep(10) 但没有帮助。
也许我在某处错过了委托,而我读委托不是必须的。 想法?
代码如下:
头文件:
#import <UIKit/UIKit.h>
#import <Foundation/Foundation.h>
@interface VisionViewController : UIViewController
{
UIImagePickerController *controller;
}
-(void)settingControllerAndTakingPicture;
@end
和实现文件
// 实现 viewDidLoad 以在加载视图后进行额外设置,通常从 nib 加载。 - (void)viewDidLoad { [超级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];
}
再说一次,我只对静音模式感兴趣。
【问题讨论】:
标签: iphone ios4 uiimagepickercontroller