1
我實現拍照功能,我需要讓用戶拍照許多他們喜歡和存儲。我能夠做到這一點,但一次只能有一張照片!用戶必須再次點擊拍照按鈕才能打開相機並拍攝照片。我試圖在保存照片後不關閉UIImagePickerController,但它不起作用!請參閱我的以下代碼。有人能告訴我如何讓用戶繼續拍照,直到他們點擊UIImagePickerController上的取消按鈕。謝謝。允許使用的UIImagePickerController直至取消按鈕拍攝照片點擊
- (IBAction)takePhoto:(id)sender
{
if ([UIImagePickerController isSourceTypeAvailable: UIImagePickerControllerSourceTypeCamera])
{
UIImagePickerController *imagePicker = [[UIImagePickerController alloc] init];
imagePicker.delegate = self;
imagePicker.sourceType = UIImagePickerControllerSourceTypeCamera;
imagePicker.mediaTypes = [NSArray arrayWithObjects:(NSString *) kUTTypeImage, nil];
[self presentModalViewController:imagePicker animated:YES];
}
}
- (void)imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary *)info
{
NSString *mediaType = [info objectForKey:UIImagePickerControllerMediaType];
if ([mediaType isEqualToString:(NSString *)kUTTypeImage])
{
UIImage *image = [info objectForKey:UIImagePickerControllerOriginalImage];
NSData *imageData = UIImageJPEGRepresentation(image, 1);
[imageData writeToFile:[delegate filePath:imageName] atomically:YES];
}
[picker dismissModalViewControllerAnimated:YES]; --> If I remove this then Camera stays open but Photo click button gets disabled! If I don't remove this it dismiss the camera.
}
- (void)imagePickerControllerDidCancel:(UIImagePickerController *)picker
{
[picker dismissModalViewControllerAnimated:YES];
}
這是不同的,那麼就是我一直在尋找。他正在嘗試以編程方式拍照。 – applefreak 2012-07-16 10:10:48