カメラでアニメーションを作成しましたが、すべて正常に動作します。カメラを起動し、画像をオーバーレイで移動して、画像として保存できます。
私の問題は、「プレビュー」でアニメーションが動き続け、カメラがいつこのモードに入るのかわからないことです。ブール値をチェックする方法や、オーバーレイを停止できる何かを行う方法がわかりません。
プレビューを維持する方法はありますか?それとも、カメラの状態を表示する機能がありますか?
御時間ありがとうございます。
// camera declaration
{
UIImagePickerController *imagePicker;
imagePicker = [[UIImagePickerController alloc] init];
imagePicker.sourceType = UIImagePickerControllerSourceTypeCamera;
imagePicker.delegate = self;
imagePicker.showsCameraControls = YES;
imagePicker.navigationBarHidden = YES;
imagePicker.toolbarHidden = YES;
imagePicker.cameraOverlayView = overlayView;
[self presentModalViewController:imagePicker animated:YES];
[self.view bringSubviewToFront:overlayView];
}
// animation
UIImageView *ani1;
ani1 = [[[UIImageView alloc] initWithImage:[UIImage imageNamed:@"ani1.png"]] autorelease];
[self.overlayView addSubview:ani1];
// loop for animation
[NSTimer scheduledTimerWithTimeInterval:0.05f target:self selector:@selector(loop) userInfo:nil repeats:YES];
-(void)loop {
// move x y each loop
newFrame = CGRectMake(x, y, 320, 480);
[ani1 setFrame:newFrame];
}
// camera finish
// take photo + overlay and save it
- (void)imagePickerController:(UIImagePickerController *)picker didFinishPickingImage:(UIImage *)image editingInfo:(NSDictionary *)editingInfo
{
imagePicker.showsCameraControls = NO;
[self presentModalViewController:imagePicker animated:NO];
[self.view bringSubviewToFront:overlayView];
UIGraphicsBeginImageContext(picker.view.bounds.size);
[picker.view.layer renderInContext:UIGraphicsGetCurrentContext()];
UIImage *newImage;
newImage = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();
UIImageWriteToSavedPhotosAlbum(newImage, nil, nil, nil);
}