以编程方式显示相机快门?

时间:2011-06-04 18:37:19

标签: objective-c cocoa-touch ios uiimagepickercontroller

为了制作我的自定义UIImagePickerSourceTypeCamera,我必须这样做:

pickerOne = [[UIImagePickerController alloc] init];
pickerOne.delegate = self;
pickerOne.sourceType = UIImagePickerControllerSourceTypeCamera;
pickerOne.showsCameraControls = NO;
pickerOne.navigationBarHidden = YES;
pickerOne.toolbarHidden = YES;
pickerOne.wantsFullScreenLayout = YES;

但现在,当我拍这样的照片时:

[cameraButton addTarget:pickerOne 
                 action:@selector(takePicture)
       forControlEvents:UIControlEventTouchUpInside];

拍摄照片时不显示快门。有没有办法以编程方式显示它?

2 个答案:

答案 0 :(得分:2)

有可能。诀窍是执行以下操作:

初始化拾取器时启用相机控件(这将启用快门视图)。

pickerOne.showsCameraControls = YES;

使用您自己的cameraButton

视图覆盖相机控件

takePicture:方法中,执行以下操作:

pickerOne.showsCameraControls = NO;
[[NSRunLoop currentRunLoop] runUntilDate:[NSDate dateWithTimeIntervalSinceNow:0.0]];
[pickerOne takePicture];

imagePickerController:didFinishPickingMediaWithInfo:方法中执行以下操作:

pickerOne.showsCameraControls = YES;  // perform on main thread

答案 1 :(得分:1)

无法控制“快门”效果。但是,您可以创建自己的图像并在其中添加效果。