简体   繁体   中英

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的功能。

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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