在iPhone中使用UIImagePickerController单击多个图像

时间:2011-04-21 09:27:47

标签: iphone uiimagepickercontroller

我无法使用相机拍摄多张图像。你能指点我一些显示如何多次调用相机的代码吗?提前谢谢。

使用的代码:

-(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]; 
 }
}

1 个答案:

答案 0 :(得分:0)

if ([respPhotoUpload.msg isEqualToString: @"Image Uploaded"])
 {
 [self dismissModalViewControllerAnimated:NO];
 [self invokeCamera];
 }
else 
 { 
  [self dismissModalViewControllerAnimated:YES]; 
 }

我不确定。使用您自己的按钮拍照,然后在完成后关闭相机,然后重新出现