简体   繁体   English

iPhone SDK相机重叠动画,如何在预览中停止?

[英]iphone sdk camera overlay animation, how can stop in preview?

I've made an animation over the camera and all works fine. 我已经在相机上制作了动画,并且一切正常。 I can start the camera, move the image in overlay, and save it as a picture. 我可以启动相机,以重叠方式移动图像,然后将其另存为图片。

My problem is that in the "preview" the animation keeps on moving, and I don't know when camera enters in this mode. 我的问题是动画在“预览”中继续移动,我不知道何时相机进入此模式。 I don't know how to check a bool or do something that can stop overlay. 我不知道如何检查布尔值或执行一些可以停止叠加的操作。

Is there any way to skeep preview? 有什么办法可以预览吗? Or does it exist some function that shows me the camera state? 还是存在一些可以显示摄像机状态的功能?

Thanks for your time. 谢谢你的时间。

// 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);
}

您将必须创建一个按钮,而不能使用Apple的默认按钮和UIImagePickerController的功能。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM