Я не могу сделать несколько снимков с помощью камеры. Не могли бы вы дать мне код, показывающий, как вызвать камеру несколько раз? Заранее спасибо.
Используемый код:
-(void) invokeCamera{
//Invoke View for Camera
if ([UIImagePickerController isSourceTypeAvailable:UIImagePickerControllerSourceTypeCamera]) {
imagePicker = [[UIImagePickerController alloc] init];
imagePicker.sourceType = UIImagePickerControllerSourceTypeCamera; imagePicker.showsCameraControls = YES;
imagePicker.delegate = self;
[self presentModalViewController:imagePicker animated:YES];
[imagePicker release];
imagePicker = nil;
}
else {
UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"Camera Unavailable" message:@"Requires a camera to take pictures" delegate:nil cancelButtonTitle:@"Continue" otherButtonTitles:nil];
[alert show];
[alert release];
}
}
(void)imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary *)info {
uploadImage = [info objectForKey:@"UIImagePickerControllerOriginalImage"];
[uploadImage retain];
indicatorView = [[UIView alloc] initWithFrame:CGRectMake(75, 155, 170, 170)]; indicatorView.backgroundColor = [UIColor colorWithRed:0 green:0 blue:0 alpha:0.5]; indicatorView.clipsToBounds = YES; //indicatorView.layer.cornerRadius = 10.0;
objIndicatorView = [[UIActivityIndicatorView alloc] initWithActivityIndicatorStyle:UIActivityIndicatorViewStyleWhiteLarge]; objIndicatorView.frame = CGRectMake(65, 40, objIndicatorView.bounds.size.width, objIndicatorView.bounds.size.height);
[indicatorView addSubview:objIndicatorView];
indicatorLabel = [[UILabel alloc] initWithFrame:CGRectMake(20, 115, 130, 22)]; indicatorLabel.backgroundColor = [UIColor clearColor];
indicatorLabel.textColor = [UIColor whiteColor];
indicatorLabel.adjustsFontSizeToFitWidth = YES;
indicatorLabel.textAlignment = UITextAlignmentCenter;
indicatorLabel.text = @"Uploading Image...";
[indicatorView addSubview:indicatorLabel];
[picker.view addSubview:indicatorView];
[picker.view bringSubviewToFront:indicatorView];
[objIndicatorView startAnimating];
[self performSelector:@selector(closeImagePicker) withObject:nil afterDelay:0.1];
}
(void)closeImagePicker{
[self formRequest: uploadImage];
if (objIndicatorView != nil)
{
[objIndicatorView stopAnimating];
[objIndicatorView removeFromSuperview];
[objIndicatorView release];
objIndicatorView = nil;
}
indicatorView.hidden = YES;
if ([respPhotoUpload.msg isEqualToString: @"Image Uploaded"])
{
[self invokeCamera];
}
else
{
[self dismissModalViewControllerAnimated:YES];
}
}