我有按钮,当我单击时会显示相机(完美运行)
- (IBAction)getPhoto:(id)sender
{
NSLog( @"Button clicked!" );
imagePicker = [[UIImagePickerController alloc] init];
imagePicker.delegate = self;
if ([UIImagePickerController isSourceTypeAvailable:UIImagePickerControllerSourceTypeCamera]) {
[imagePicker setSourceType:UIImagePickerControllerSourceTypeCamera];
}
else { // IF the device doesn't have a camera, so use the photos album
[imagePicker setSourceType:UIImagePickerControllerSourceTypeSavedPhotosAlbum];
}
[self addSubview:imagePicker.view];
}
之后我可以拍摄图像等,但是当我单击“使用”时:这里什么都没有发生是我的方法:图像选择器不会关闭其自身:应用程序根本什么都不做,我正在尝试拍摄我刚刚拍摄的图像将其显示在屏幕上的 CGRect 中。
- (void)imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary *)info {
[picker dismissViewControllerAnimated:YES completion:NULL];
UIImageView *patientImage = [[UIImageView alloc] init];
patientImage.frame = CGRectMake(625, 25, 83, 103);
UIImage *chosenImage = info[UIImagePickerControllerEditedImage];
self.patientImage.image = chosenImage;
}
即使我在没有拍摄图像的情况下点击取消按钮,imagePicker(相机界面)也不会自行关闭
任何帮助、建议或指导将不胜感激。