写真撮影に使用UIImagePickercontroller
しています。の下に画像がありますUIScrollview
。スクロールビューから特定の画像をクリックすると、画像はimageViewのサブビューになります。そして、オーバーレイの cameraView に imageView が表示されます。特定の画像をcameraViewの上から下または任意の場所に移動すると、オーバーレイで写真を撮る必要があります。しかし、オーバーレイで写真をキャプチャすることはできません。
コード:
picker = [[UIImagePickerController alloc] init];
// Set the image picker source:
// picker.sourceType = UIImagePickerControllerSourceTypeCamera;
// Hide the controls:
picker.showsCameraControls = YES;
picker.navigationBarHidden = YES;
picker.delegate=self;
// Make camera view full screen:
picker.wantsFullScreenLayout = YES;
// Insert the overlay:
picker.cameraOverlayView = self.view;
self.view.backgroundColor=[UIColor clearColor];
// Show the picker:
[self presentModalViewController:picker animated:YES];
-(void)imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary *)info
{
UIImage *image = [info objectForKey:@"UIImagePickerControllerOriginalImage"];
UIImageWriteToSavedPhotosAlbum(image,self,
@selector(image:finishedSavingWithError:contextInfo:),
nil);
}
- (void)image:(UIImage *)image didFinishSavingWithError:(NSError *)error contextInfo:(void *)contextInfo
{
UIAlertView *alert;
if (error)
alert = [[UIAlertView alloc] initWithTitle:@"Error"
message:@"Unable to save image to Photo Album."
delegate:self cancelButtonTitle:@"Ok"
otherButtonTitles:nil];
else
alert = [[UIAlertView alloc] initWithTitle:@"Success"
message:@"Image saved to Photo Album."
delegate:self cancelButtonTitle:@"Ok"
otherButtonTitles:nil];
[alert show];
// [alert release];
}