开发者

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];
 i开发者_开发百科magePicker.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);
}


You would have to create your one buttons and not use apple's default buttons and features of the UIImagePickerController.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜