我正在尝试制作我的第一个 iOS 应用程序,但在获取刚刚拍摄的照片时遇到了一些问题。
这是我的方法:
- (void)viewDidLoad
{
[super viewDidLoad];
//add imagePicker
_imgPicker = [[UIImagePickerController alloc] init];
_imgPicker.sourceType = UIImagePickerControllerSourceTypeCamera;
_imgPicker.cameraCaptureMode = UIImagePickerControllerCameraCaptureModePhoto;
_imgPicker.cameraDevice = UIImagePickerControllerCameraDeviceFront;
_imgPicker.showsCameraControls = NO;
_imgPicker.navigationBarHidden = YES;
_imgPicker.toolbarHidden = YES;
_imgPicker.wantsFullScreenLayout = NO;
//add overlay on imagePicker
_imageSilhouette.image = [UIImage imageNamed:_pose.image];
_imgPicker.cameraOverlayView = _imageSilhouette;
[_vImagePreview addSubview:_imgPicker.view];
}
当我点击一个按钮时,我有一个计时器,10秒后,我拍照:
- (void)decreaseTimerCount
{
_lblTimer.text = [NSString stringWithFormat:@"%d", --_timerCount];
if(_timerCount==0)
{
[self takePicture];
}
}
-(void) takePicture{
[_timer invalidate];
[_imgPicker takePicture];
}
正如我在 Apple 文档中看到的,我添加了委托:
- (void)imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary *)info
{
UIImage * img = [info objectForKey:UIImagePickerControllerOriginalImage];
_imageSilhouette.image = img;
_imgPicker.cameraOverlayView = _imageSilhouette;
//[picker dismissModalViewControllerAnimated:YES];
}
但我真的不明白我是否必须在某处声明 imagePickerController ..
我也不明白 img 是否包含我刚拍的照片?
我能帮忙吗?